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

kvserver/rangefeed: wrap muxer inside setRangeIDEventSink #126489

Merged
merged 3 commits into from
Jul 11, 2024

Conversation

wenyihu6
Copy link
Contributor

@wenyihu6 wenyihu6 commented Jul 1, 2024

kvserver/rangefeed: remove unused cancel

This patch removes the unused field cancel from setRangeIDEventSink.

Epic: none
Release note: none


kvserver/rangefeed: wrap muxer inside setRangeIDEventSink

Previously, each rangefeed stream setRangeIDEventSink wrapped the underlying
muxstream to send to grpc stream. This patch changes the stream to wrap the
stream muxer struct instead which itself wraps the underlying muxstream.

Note that this patch doesn’t change any existing behavior but only to make
future commits cleaner when we change muxer to send data to a buffered stream
instead of directly to grpc.

Part of: #126561
Release note: none


kvserver/rangefeed: rename setRangeIDEventSink to perRangeEventSink

This patch renames setRangeIDEventSink to perRangeEventSink for clarity.

Epic: none
Release note: none

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@wenyihu6 wenyihu6 changed the title Addmuxer2 kvserver/rangefeed: wrap muxer inside setRangeIDEventSink Jul 1, 2024
@wenyihu6 wenyihu6 marked this pull request as ready for review July 1, 2024 14:07
@wenyihu6 wenyihu6 requested a review from a team July 1, 2024 14:07
@wenyihu6 wenyihu6 requested review from a team as code owners July 1, 2024 14:07
@wenyihu6 wenyihu6 requested a review from nvanbenschoten July 1, 2024 14:10
This patch removes the unused field cancel from setRangeIDEventSink.

Epic: none
Release note: none
Copy link
Contributor Author

@wenyihu6 wenyihu6 left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten)


pkg/server/node.go line 1841 at r2 (raw file):

	Send(event *kvpb.MuxRangeFeedEvent) error
	SendIsThreadSafe()
}

I added an interface to abstract the methods of rangefeed.StreamMuxer. We could also just store the actual *rangefeed.StreamMuxer here, but I thought using an interface here makes the purpose of stream muxer in this package clearer. In the future, we will start adding methods like StreamMuxer.DisconnectStreamWithError to remove future package, but it should never need other methods like StreamMuxer.Run. Do you think this makes sense?

Copy link
Member

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @wenyihu6)


pkg/server/node.go line 1841 at r2 (raw file):

Previously, wenyihu6 (Wenyi Hu) wrote…

I added an interface to abstract the methods of rangefeed.StreamMuxer. We could also just store the actual *rangefeed.StreamMuxer here, but I thought using an interface here makes the purpose of stream muxer in this package clearer. In the future, we will start adding methods like StreamMuxer.DisconnectStreamWithError to remove future package, but it should never need other methods like StreamMuxer.Run. Do you think this makes sense?

Will there be multiple implementations of this interface? If not, then I don't think the interface is buying us much beyond making the code a little harder to understand and breaking jump-to-definition.


pkg/server/node.go line 1845 at r2 (raw file):

var _ muxer = &rangefeed.StreamMuxer{}

// setRangeIDEventSink is an implementation of rangefeed.Stream which annotates

Unrelated to this change, but what do you think of this name? I keep thinking it's a function that "sets a range ID on an event sink". Any appetite to switching to something like rangeBoundEventSink or perRangeEventSink which makes it more clear how the type relates to the other streams?

Previously, each rangefeed stream setRangeIDEventSink wrapped the underlying
muxstream to send to grpc stream. This patch changes the stream to wrap the
stream muxer struct instead which itself wraps the underlying muxstream.

Note that this patch doesn’t change any existing behavior but only to make
future commits cleaner when we change muxer to send data to a buffered stream
instead of directly to grpc.

Part of: cockroachdb#126561
Release note: none
This patch renames `setRangeIDEventSink` to `perRangeEventSink` for clarity.

Epic: none
Release note: none
Copy link
Contributor Author

@wenyihu6 wenyihu6 left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @nvanbenschoten)


pkg/server/node.go line 1841 at r2 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Will there be multiple implementations of this interface? If not, then I don't think the interface is buying us much beyond making the code a little harder to understand and breaking jump-to-definition.

No, there will only be one implementation of this interface. Agree, I've removed the interface and only stored the actual struct.


pkg/server/node.go line 1845 at r2 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Unrelated to this change, but what do you think of this name? I keep thinking it's a function that "sets a range ID on an event sink". Any appetite to switching to something like rangeBoundEventSink or perRangeEventSink which makes it more clear how the type relates to the other streams?

I like perRangeEventSink! I added another commit for this.

Copy link
Member

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 3 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @wenyihu6)

@wenyihu6
Copy link
Contributor Author

TFTR!

bors r=nvanbenschoten

@craig craig bot merged commit c70c485 into cockroachdb:master Jul 11, 2024
22 checks passed
@wenyihu6 wenyihu6 deleted the addmuxer2 branch July 18, 2024 18:38
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.

3 participants