Debian Codegraph @

confmap/converter.go

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