draincloud-core/internal/config/config.go

78 lines
1005 B
Go
Raw Normal View History

2024-10-11 19:37:43 +00:00
package config
import (
"context"
"time"
)
type Provider interface {
GetValue(ctx context.Context, key Key) Value
}
type Key string
type Value interface {
Int() int
String() string
Float() float32
Duration() time.Duration
}
type DurationValue time.Duration
type FloatValue float32
type StringValue string
func (v StringValue) Int() int {
return 0
}
func (v StringValue) String() string {
return string(v)
}
func (v StringValue) Float() float32 {
return 0
}
func (v StringValue) Duration() time.Duration {
return 0
}
type EmptyValue struct{}
func (v EmptyValue) Int() int {
return 0
}
func (v EmptyValue) String() string {
return ""
}
func (v EmptyValue) Float() float32 {
return 0
}
func (v EmptyValue) Duration() time.Duration {
return 0
}
type IntValue int
func (v IntValue) Int() int {
return int(v)
}
func (v IntValue) String() string {
return ""
}
func (v IntValue) Float() float32 {
return float32(v)
}
func (v IntValue) Duration() time.Duration {
return 0
}