| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
package queuebatch |
| 5 |
|
| 6 |
import ( |
| 7 |
"context" |
| 8 |
|
| 9 |
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/request" |
| 10 |
) |
| 11 |
|
| 12 |
|
| 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 |
} |