-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathconverter.go
38 lines (30 loc) · 1.33 KB
/
converter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package confmap // import "go.opentelemetry.io/collector/confmap"
import (
"context"
"go.uber.org/zap"
)
// ConverterSettings are the settings to initialize a Converter.
type ConverterSettings struct {
// Logger is a zap.Logger that will be passed to Converters.
// Converters should be able to rely on the Logger being non-nil;
// when instantiating a Converter with a ConverterFactory,
// nil Logger references should be replaced with a no-op Logger.
Logger *zap.Logger
}
// ConverterFactory defines a factory that can be used to instantiate
// new instances of a Converter.
type ConverterFactory = moduleFactory[Converter, ConverterSettings]
// CreateConverterFunc is a function that creates a Converter instance.
type CreateConverterFunc = createConfmapFunc[Converter, ConverterSettings]
// NewConverterFactory can be used to create a ConverterFactory.
func NewConverterFactory(f CreateConverterFunc) ConverterFactory {
return newConfmapModuleFactory(f)
}
// Converter is a converter interface for the confmap.Conf that allows distributions
// (in the future components as well) to build backwards compatible config converters.
type Converter interface {
// Convert applies the conversion logic to the given "conf".
Convert(ctx context.Context, conf *Conf) error
}