Skip to content

Commit c56d8f6

Browse files
authored
[chore] Use T for generics instead of K, consistent with rest of the repo (#12755)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
1 parent dae1d8e commit c56d8f6

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

exporter/exporterhelper/internal/queue_sender.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import (
1919
)
2020

2121
// QueueBatchSettings is a subset of the queuebatch.Settings that are needed when used within an Exporter.
22-
type QueueBatchSettings[K any] struct {
23-
Encoding queuebatch.Encoding[K]
24-
Sizers map[request.SizerType]request.Sizer[K]
22+
type QueueBatchSettings[T any] struct {
23+
Encoding queuebatch.Encoding[T]
24+
Sizers map[request.SizerType]request.Sizer[T]
2525
}
2626

2727
// NewDefaultQueueConfig returns the default config for queuebatch.Config.

exporter/exporterhelper/internal/queuebatch/batcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
// Batcher is in charge of reading items from the queue and send them out asynchronously.
13-
type Batcher[K any] interface {
13+
type Batcher[T any] interface {
1414
component.Component
15-
Consume(context.Context, K, Done)
15+
Consume(context.Context, T, Done)
1616
}

exporter/exporterhelper/internal/queuebatch/default_batcher.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ type batch struct {
2121
done multiDone
2222
}
2323

24-
type batcherSettings[K any] struct {
24+
type batcherSettings[T any] struct {
2525
sizerType request.SizerType
26-
sizer request.Sizer[K]
27-
next sender.SendFunc[K]
26+
sizer request.Sizer[T]
27+
next sender.SendFunc[T]
2828
maxWorkers int
2929
}
3030

exporter/exporterhelper/internal/queuebatch/disabled_batcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ func (db *disabledBatcher[T]) Consume(ctx context.Context, req T, done Done) {
2222
done.OnDone(db.consumeFunc(ctx, req))
2323
}
2424

25-
func newDisabledBatcher[K any](consumeFunc sender.SendFunc[K]) Batcher[K] {
26-
return &disabledBatcher[K]{consumeFunc: consumeFunc}
25+
func newDisabledBatcher[T any](consumeFunc sender.SendFunc[T]) Batcher[T] {
26+
return &disabledBatcher[T]{consumeFunc: consumeFunc}
2727
}

exporter/exporterhelper/internal/queuebatch/queue_batch.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import (
1515
)
1616

1717
// Settings defines settings for creating a QueueBatch.
18-
type Settings[K any] struct {
18+
type Settings[T any] struct {
1919
Signal pipeline.Signal
2020
ID component.ID
2121
Telemetry component.TelemetrySettings
22-
Encoding Encoding[K]
23-
Sizers map[request.SizerType]request.Sizer[K]
22+
Encoding Encoding[T]
23+
Sizers map[request.SizerType]request.Sizer[T]
2424
}
2525

2626
type QueueBatch struct {

exporter/exporterhelper/internal/sender/sender.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ import (
99
"go.opentelemetry.io/collector/component"
1010
)
1111

12-
type Sender[K any] interface {
12+
type Sender[T any] interface {
1313
component.Component
14-
Send(context.Context, K) error
14+
Send(context.Context, T) error
1515
}
1616

17-
type SendFunc[K any] func(ctx context.Context, data K) error
17+
type SendFunc[T any] func(ctx context.Context, data T) error
1818

19-
func NewSender[K any](consFunc SendFunc[K]) Sender[K] {
20-
return &sender[K]{consFunc: consFunc}
19+
func NewSender[T any](consFunc SendFunc[T]) Sender[T] {
20+
return &sender[T]{consFunc: consFunc}
2121
}
2222

2323
// sender is a Sender that emits the incoming request to the exporter consumer func.
24-
type sender[K any] struct {
24+
type sender[T any] struct {
2525
component.StartFunc
2626
component.ShutdownFunc
27-
consFunc SendFunc[K]
27+
consFunc SendFunc[T]
2828
}
2929

30-
func (es *sender[K]) Send(ctx context.Context, req K) error {
30+
func (es *sender[T]) Send(ctx context.Context, req T) error {
3131
return es.consFunc(ctx, req)
3232
}

exporter/exporterhelper/internal/sendertest/sendertest.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/sender"
1010
)
1111

12-
func NewNopSenderFunc[K any]() sender.SendFunc[K] {
13-
return func(context.Context, K) error {
12+
func NewNopSenderFunc[T any]() sender.SendFunc[T] {
13+
return func(context.Context, T) error {
1414
return nil
1515
}
1616
}
1717

18-
func NewErrSenderFunc[K any](err error) sender.SendFunc[K] {
19-
return func(context.Context, K) error {
18+
func NewErrSenderFunc[T any](err error) sender.SendFunc[T] {
19+
return func(context.Context, T) error {
2020
return err
2121
}
2222
}

exporter/exporterhelper/internal/timeout_sender.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ func NewDefaultTimeoutConfig() TimeoutConfig {
3535
}
3636

3737
// timeoutSender is a requestSender that adds a `timeout` to every request that passes this sender.
38-
type timeoutSender[K any] struct {
38+
type timeoutSender[T any] struct {
3939
component.StartFunc
4040
component.ShutdownFunc
4141
cfg TimeoutConfig
42-
next sender.Sender[K]
42+
next sender.Sender[T]
4343
}
4444

45-
func newTimeoutSender[K any](cfg TimeoutConfig, next sender.Sender[K]) sender.Sender[K] {
46-
return &timeoutSender[K]{cfg: cfg, next: next}
45+
func newTimeoutSender[T any](cfg TimeoutConfig, next sender.Sender[T]) sender.Sender[T] {
46+
return &timeoutSender[T]{cfg: cfg, next: next}
4747
}
4848

49-
func (ts *timeoutSender[K]) Send(ctx context.Context, req K) error {
49+
func (ts *timeoutSender[T]) Send(ctx context.Context, req T) error {
5050
// Intentionally don't overwrite the context inside the request, because in case of retries deadline will not be
5151
// updated because this deadline most likely is before the next one.
5252
tCtx, cancelFunc := context.WithTimeout(ctx, ts.cfg.Timeout)

exporter/exporterhelper/request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type RequestErrorHandler = request.ErrorHandler
2626
// RequestConverterFunc converts pdata telemetry into a user-defined Request.
2727
// Experimental: This API is at the early stage of development and may change without backward compatibility
2828
// until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
29-
type RequestConverterFunc[K any] func(context.Context, K) (Request, error)
29+
type RequestConverterFunc[T any] func(context.Context, T) (Request, error)
3030

3131
// RequestConsumeFunc processes the request. After the function returns, the request is no longer accessible,
3232
// and accessing it is considered undefined behavior.

0 commit comments

Comments
 (0)