Debian Codegraph @

exporter/exporterhelper/internal/sender/sender.go

raw symbols SCIP
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package sender // import "go.opentelemetry.io/collector/exporter/exporterhelper/internal/sender"
5
6 import (
7 "context"
8
9 "go.opentelemetry.io/collector/component"
10 )
11
12 type Sender[T any] interface {
13 component.Component
14 Send(context.Context, T) error
15 }
16
17 type SendFunc[T any] func(ctx context.Context, data T) error
18
19 func NewSender[T any](consFunc SendFunc[T]) Sender[T] {
20 return &sender[T]{consFunc: consFunc}
21 }
22
23 // sender is a Sender that emits the incoming request to the exporter consumer func.
24 type sender[T any] struct {
25 component.StartFunc
26 component.ShutdownFunc
27 consFunc SendFunc[T]
28 }
29
30 func (es *sender[T]) Send(ctx context.Context, req T) error {
31 return es.consFunc(ctx, req)
32 }