Debian Codegraph @

exporter/exporterhelper/internal/queuebatch/partitioner.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/exporter/exporterhelper/internal/request"
10 )
11
12 // Partitioner is an interface that returns the the partition key of the given element.
13 type Partitioner[T any] interface {
14 GetKey(context.Context, T) string
15 }
16
17 type GetKeyFunc[T any] func(context.Context, T) string
18
19 func (f GetKeyFunc[T]) GetKey(ctx context.Context, t T) string {
20 return f(ctx, t)
21 }
22
23 type basePartitioner struct {
24 GetKeyFunc[request.Request]
25 }
26
27 func NewPartitioner(
28 getKeyFunc GetKeyFunc[request.Request],
29 ) Partitioner[request.Request] {
30 return &basePartitioner{
31 GetKeyFunc: getKeyFunc,
32 }
33 }