Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions internal/dispatch/combined/combined.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@
secondaryClients[name] = remote.SecondaryDispatch{
Name: name,
Client: v1.NewDispatchServiceClient(secondaryConn),
Conn: secondaryConn,

Check warning on line 295 in internal/dispatch/combined/combined.go

View check run for this annotation

Codecov / codecov/patch

internal/dispatch/combined/combined.go#L295

Added line #L295 was not covered by tests
MaximumPrimaryHedgingDelay: maximumHedgingDelay,
}
}
Expand Down
18 changes: 16 additions & 2 deletions internal/dispatch/remote/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@
// Client is the client to use for dispatching to the secondary.
Client ClusterClient

// Conn is the underlying gRPC connection for the secondary dispatcher, used for closing.
// May be nil if the client is a mock or test double.
Conn *grpc.ClientConn

// MaximumHedgingDelay is the maximum delay that the primary will wait before dispatching
// when this secondary is active.
MaximumPrimaryHedgingDelay time.Duration
Expand Down Expand Up @@ -914,10 +918,20 @@
}

func (cr *clusterDispatcher) Close() error {
var firstErr error

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Prefer errors.Join here

for _, secondary := range cr.secondaryDispatch {
if secondary.Conn != nil {
if err := secondary.Conn.Close(); err != nil && firstErr == nil {
firstErr = err
}

Check warning on line 926 in internal/dispatch/remote/cluster.go

View check run for this annotation

Codecov / codecov/patch

internal/dispatch/remote/cluster.go#L923-L926

Added lines #L923 - L926 were not covered by tests
}
}
if cr.conn != nil {
return cr.conn.Close()
if err := cr.conn.Close(); err != nil && firstErr == nil {
firstErr = err
}
}
return nil
return firstErr
}

// ReadyState returns whether the underlying dispatch connection is available
Expand Down
Loading