Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changefeedccl: reduce direct access to changefeeddetails #83153

Merged
merged 1 commit into from
Jun 24, 2022

Conversation

HonoreDB
Copy link
Contributor

Directly referencing fields on the jobs proto makes
inter-version compatibility harder.
This PR takes a first step toward making most methods use
changefeedbase objects instead.

Fixes #82342.

Release note: None

@HonoreDB HonoreDB requested a review from a team as a code owner June 21, 2022 20:54
@HonoreDB HonoreDB requested review from livlobo and removed request for a team June 21, 2022 20:54
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@HonoreDB HonoreDB force-pushed the marker_types branch 2 times, most recently from b570bd7 to fc01403 Compare June 22, 2022 13:15
Copy link
Contributor

@miretskiy miretskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice; mostly nits.

StatementTimeName StatementTimeName
}

type StatementTimeName string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint would probably complain about lack of comments on exported symbols.
(even if it won't, we probably should have those).


type StatementTimeName string
type WatchedTables map[descpb.ID]StatementTimeName
type Targets []Target
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we imagine having methods on Targets? If not, perhaps we should use []Target at the call sites?

@@ -22,6 +23,75 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/uuid"
)

// Changefeed provides a version-agnostic wrapper around jobspb.ChangefeedDetails.
type Changefeed struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would mildly prefer not to call this Changefeed, but something more specific.
Maybe one one of (CDC|Feed|Changefeed)(Config|Cfg)?

Targets changefeedbase.Targets
}

func makeChangefeedFromJobDetails(d jobspb.ChangefeedDetails) Changefeed {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function comment por favore.

@@ -389,7 +389,9 @@ func (s *bufferSink) Dial() error {
// TODO (zinger): Make this a tuple or array datum if it can be
// done without breaking backwards compatibility.
func (s *bufferSink) getTopicDatum(t TopicDescriptor) *tree.DString {
return s.alloc.NewDString(tree.DString(strings.Join(t.GetNameComponents(), ".")))
name, components := t.GetNameComponents()
strs := append([]string{string(name)}, components...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit sad that we have to alloc new array every time...
Do you think we can/should special case when we have nil components?

@HonoreDB HonoreDB force-pushed the marker_types branch 2 times, most recently from c9cb790 to f3bbeec Compare June 22, 2022 19:54
Copy link
Contributor Author

@HonoreDB HonoreDB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @livlobo and @miretskiy)


pkg/ccl/changefeedccl/changefeed.go line 27 at r1 (raw file):

Previously, miretskiy (Yevgeniy Miretskiy) wrote…

I would mildly prefer not to call this Changefeed, but something more specific.
Maybe one one of (CDC|Feed|Changefeed)(Config|Cfg)?

Changed to ChangefeedConfig.


pkg/ccl/changefeedccl/changefeed.go line 44 at r1 (raw file):

Previously, miretskiy (Yevgeniy Miretskiy) wrote…

Function comment por favore.

Done.


pkg/ccl/changefeedccl/sink.go line 393 at r1 (raw file):

Previously, miretskiy (Yevgeniy Miretskiy) wrote…

a bit sad that we have to alloc new array every time...
Do you think we can/should special case when we have nil components?

Done.


pkg/ccl/changefeedccl/changefeedbase/target.go line 24 at r1 (raw file):

Previously, miretskiy (Yevgeniy Miretskiy) wrote…

lint would probably complain about lack of comments on exported symbols.
(even if it won't, we probably should have those).

Done.


pkg/ccl/changefeedccl/changefeedbase/target.go line 26 at r1 (raw file):

Previously, miretskiy (Yevgeniy Miretskiy) wrote…

Do we imagine having methods on Targets? If not, perhaps we should use []Target at the call sites?

I am imagining having methods on Targets in a future PR, yeah, I think probably the thing to do is consolidate it and WatchedTables into one type that you can efficiently access in different ways (EachTarget, EachTable, FindStatementTimeNameByID).

Directly referencing fields on the jobs proto makes
inter-version compatibility harder.
This PR takes a first step toward making most methods use
changefeedbase objects instead.

Release note: None
@HonoreDB
Copy link
Contributor Author

bors r=[miretskiy]

@craig
Copy link
Contributor

craig bot commented Jun 23, 2022

Build failed:

@HonoreDB
Copy link
Contributor Author

bors retry

@livlobo livlobo removed their request for review June 24, 2022 13:33
@craig
Copy link
Contributor

craig bot commented Jun 24, 2022

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

changefeedccl: Add marker type for "target specification"
3 participants