forked from GoCodeAlone/modular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstance_aware_config.go
More file actions
31 lines (26 loc) · 1.08 KB
/
instance_aware_config.go
File metadata and controls
31 lines (26 loc) · 1.08 KB
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
package modular
// InstanceAwareConfigProvider handles configuration for multiple instances of the same type
type InstanceAwareConfigProvider struct {
cfg any
instancePrefixFunc InstancePrefixFunc
}
// NewInstanceAwareConfigProvider creates a new instance-aware configuration provider
func NewInstanceAwareConfigProvider(cfg any, prefixFunc InstancePrefixFunc) *InstanceAwareConfigProvider {
return &InstanceAwareConfigProvider{
cfg: cfg,
instancePrefixFunc: prefixFunc,
}
}
// GetConfig returns the configuration object
func (p *InstanceAwareConfigProvider) GetConfig() any {
return p.cfg
}
// GetInstancePrefixFunc returns the instance prefix function
func (p *InstanceAwareConfigProvider) GetInstancePrefixFunc() InstancePrefixFunc {
return p.instancePrefixFunc
}
// InstanceAwareConfigSupport indicates that a configuration supports instance-aware feeding
type InstanceAwareConfigSupport interface {
// GetInstanceConfigs returns a map of instance configurations that should be fed with instance-aware feeders
GetInstanceConfigs() map[string]interface{}
}