MCPcopy Create free account
hub / github.com/google/go-cloud / Add

Method Add

pubsub/batcher/batcher.go:162–171  ·  view source on GitHub ↗

Add adds an item to the batcher. It blocks until the handler has processed the item and reports the error that the handler returned. If Shutdown has been called, Add immediately returns an error.

(ctx context.Context, item any)

Source from the content-addressed store, hash-verified

160// processed the item and reports the error that the handler returned.
161// If Shutdown has been called, Add immediately returns an error.
162func (b *Batcher) Add(ctx context.Context, item any) error {
163 c := b.AddNoWait(item)
164 // Wait until either our result is ready or the context is done.
165 select {
166 case err := <-c:
167 return err
168 case <-ctx.Done():
169 return ctx.Err()
170 }
171}
172
173// AddNoWait adds an item to the batcher and returns immediately. When the handler is
174// called on the item, the handler's error return value will be sent to the channel

Calls 3

AddNoWaitMethod · 0.95
DoneMethod · 0.80
ErrMethod · 0.80