newSendBatcher creates a batcher for topics, for use with NewTopic.
(ctx context.Context, t *Topic, dt driver.Topic, opts *batcher.Options)
| 326 | |
| 327 | // newSendBatcher creates a batcher for topics, for use with NewTopic. |
| 328 | func 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 | // |