-
Notifications
You must be signed in to change notification settings - Fork 23
/
config_unmarshaller.go
36 lines (27 loc) · 1.01 KB
/
config_unmarshaller.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
package config
import (
"context"
"go.opentelemetry.io/collector/confmap"
)
const schemeName = "file"
// OTelConfigUnmarshaller can be used as an OTel config map provider.
type OTelConfigUnmarshaller struct {
config map[string]interface{}
}
// NewOTelConfigUnmarshaler creates a new OTelConfigUnmarshaler instance.
func NewOTelConfigUnmarshaler(config map[string]interface{}) *OTelConfigUnmarshaller {
return &OTelConfigUnmarshaller{config: config}
}
// Implements MapProvider interface
// Retrieve returns the value to be injected in the configuration and the corresponding watcher.
func (u *OTelConfigUnmarshaller) Retrieve(_ context.Context, _ string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) {
return confmap.NewRetrieved(u.config)
}
// Shutdown indicates the provider should close.
func (u *OTelConfigUnmarshaller) Shutdown(ctx context.Context) error {
return nil
}
// Scheme returns the scheme name, location scheme used by Retrieve.
func (u *OTelConfigUnmarshaller) Scheme() string {
return schemeName
}