MCPcopy
hub / github.com/github/gh-ost / SendWithContext

Function SendWithContext

go/base/context.go:1047–1054  ·  view source on GitHub ↗

SendWithContext attempts to send a value to a channel, but returns early if the context is cancelled. This prevents goroutine deadlocks when the channel receiver has exited due to an error. Use this instead of bare channel sends (ch <- val) in goroutines to ensure proper cleanup when the migration

(ctx context.Context, ch chan<- T, val T)

Source from the content-addressed store, hash-verified

1045// return err // context was cancelled
1046// }
1047func SendWithContext[T any](ctx context.Context, ch chan<- T, val T) error {
1048 select {
1049 case ch <- val:
1050 return nil
1051 case <-ctx.Done():
1052 return ctx.Err()
1053 }
1054}

Callers 13

applyServerCommandMethod · 0.92
retryOperationMethod · 0.92
onChangelogStateEventMethod · 0.92
MigrateMethod · 0.92
RevertMethod · 0.92
initiateStreamingMethod · 0.92
addDMLEventsListenerMethod · 0.92
iterateChunksMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…