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

Function newSendBatcher

pubsub/pubsub.go:328–342  ·  view source on GitHub ↗

newSendBatcher creates a batcher for topics, for use with NewTopic.

(ctx context.Context, t *Topic, dt driver.Topic, opts *batcher.Options)

Source from the content-addressed store, hash-verified

326
327// newSendBatcher creates a batcher for topics, for use with NewTopic.
328func newSendBatcher(ctx context.Context, t *Topic, dt driver.Topic, opts *batcher.Options) *batcher.Batcher {
329 handler := func(items any) error {
330 dms := items.([]*driver.Message)
331 err := retry.Call(ctx, gax.Backoff{}, dt.IsRetryable, func() (err error) {
332 spanCtx, span := t.tracer.Start(ctx, "driver.Topic.SendBatch")
333 defer func() { t.tracer.End(spanCtx, span, err) }()
334 return dt.SendBatch(spanCtx, dms)
335 })
336 if err != nil {
337 return wrapError(dt, err)
338 }
339 return nil
340 }
341 return batcher.New(reflect.TypeFor[*driver.Message](), opts, handler)
342}
343
344// newTopic makes a pubsub.Topic from a driver.Topic.
345//

Callers 1

newTopicFunction · 0.85

Calls 6

CallFunction · 0.92
NewFunction · 0.92
StartMethod · 0.80
EndMethod · 0.80
wrapErrorFunction · 0.70
SendBatchMethod · 0.65

Tested by

no test coverage detected