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

opt: delete redundant channel connection.incomingCmdCh #1343

Merged
merged 3 commits into from
Mar 7, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions pulsar/internal/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ type request struct {
callback func(command *pb.BaseCommand, err error)
}

type incomingCmd struct {
cmd *pb.BaseCommand
headersAndPayload Buffer
}

type connection struct {
started int32
connectionTimeout time.Duration
Expand All @@ -160,7 +155,6 @@ type connection struct {

incomingRequestsWG sync.WaitGroup
incomingRequestsCh chan *request
incomingCmdCh chan *incomingCmd
closeCh chan struct{}
readyCh chan struct{}
writeRequestsCh chan Buffer
Expand Down Expand Up @@ -209,7 +203,6 @@ func newConnection(opts connectionOptions) *connection {
closeCh: make(chan struct{}),
readyCh: make(chan struct{}),
incomingRequestsCh: make(chan *request, 10),
incomingCmdCh: make(chan *incomingCmd, 10),

// This channel is used to pass data from producers to the connection
// go routine. It can become contended or blocking if we have multiple
Expand Down Expand Up @@ -438,9 +431,6 @@ func (c *connection) run() {
select {
case <-c.closeCh:
return

case cmd := <-c.incomingCmdCh:
c.internalReceivedCommand(cmd.cmd, cmd.headersAndPayload)
case data := <-c.writeRequestsCh:
if data == nil {
return
Expand Down Expand Up @@ -534,7 +524,7 @@ func (c *connection) writeCommand(cmd *pb.BaseCommand) {
}

func (c *connection) receivedCommand(cmd *pb.BaseCommand, headersAndPayload Buffer) {
c.incomingCmdCh <- &incomingCmd{cmd, headersAndPayload}
c.internalReceivedCommand(cmd, headersAndPayload)
}

func (c *connection) internalReceivedCommand(cmd *pb.BaseCommand, headersAndPayload Buffer) {
Expand Down
Loading