Debian Codegraph @

exporter/exporterhelper/internal/queuebatch/disabled_batcher.go

raw symbols SCIP
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package queuebatch // import "go.opentelemetry.io/collector/exporter/exporterhelper/internal/queuebatch"
5
6 import (
7 "context"
8
9 "go.opentelemetry.io/collector/component"
10 "go.opentelemetry.io/collector/exporter/exporterhelper/internal/queue"
11 "go.opentelemetry.io/collector/exporter/exporterhelper/internal/sender"
12 )
13
14 // disabledBatcher is a special-case of Batcher that has no size limit for sending. Any items read from the queue will
15 // be sent out (asynchronously) immediately regardless of the size.
16 type disabledBatcher[T any] struct {
17 component.StartFunc
18 component.ShutdownFunc
19 consumeFunc sender.SendFunc[T]
20 }
21
22 func (db *disabledBatcher[T]) Consume(ctx context.Context, req T, done queue.Done) {
23 done.OnDone(db.consumeFunc(ctx, req))
24 }
25
26 func newDisabledBatcher[T any](consumeFunc sender.SendFunc[T]) Batcher[T] {
27 return &disabledBatcher[T]{consumeFunc: consumeFunc}
28 }