[chore] Make internal Batcher interface generic (#12689)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
This commit is contained in:
parent
562aedc665
commit
f1bdeb3c43
|
|
@ -14,17 +14,14 @@ import (
|
|||
)
|
||||
|
||||
// Batcher is in charge of reading items from the queue and send them out asynchronously.
|
||||
type Batcher interface {
|
||||
type Batcher[K any] interface {
|
||||
component.Component
|
||||
Consume(context.Context, request.Request, queuebatch.Done)
|
||||
Consume(context.Context, K, queuebatch.Done)
|
||||
}
|
||||
|
||||
func NewBatcher(batchCfg exporterbatcher.Config,
|
||||
exportFunc sender.SendFunc[request.Request],
|
||||
maxWorkers int,
|
||||
) (Batcher, error) {
|
||||
func NewBatcher(batchCfg exporterbatcher.Config, exportFunc sender.SendFunc[request.Request], maxWorkers int) (Batcher[request.Request], error) {
|
||||
if !batchCfg.Enabled {
|
||||
return newDisabledBatcher(exportFunc), nil
|
||||
return newDisabledBatcher[request.Request](exportFunc), nil
|
||||
}
|
||||
return newDefaultBatcher(batchCfg, exportFunc, maxWorkers), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/queuebatch"
|
||||
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/request"
|
||||
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/sender"
|
||||
)
|
||||
|
||||
|
|
@ -24,6 +23,6 @@ func (db *disabledBatcher[T]) Consume(ctx context.Context, req T, done queuebatc
|
|||
done.OnDone(db.consumeFunc(ctx, req))
|
||||
}
|
||||
|
||||
func newDisabledBatcher(consumeFunc sender.SendFunc[request.Request]) Batcher {
|
||||
return &disabledBatcher[request.Request]{consumeFunc: consumeFunc}
|
||||
func newDisabledBatcher[K any](consumeFunc sender.SendFunc[K]) Batcher[K] {
|
||||
return &disabledBatcher[K]{consumeFunc: consumeFunc}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import (
|
|||
|
||||
type QueueSender struct {
|
||||
queue queuebatch.Queue[request.Request]
|
||||
batcher component.Component
|
||||
batcher batcher.Batcher[request.Request]
|
||||
}
|
||||
|
||||
func NewQueueSender(
|
||||
|
|
|
|||
Loading…
Reference in New Issue