-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.go
48 lines (39 loc) · 1.45 KB
/
config.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
39
40
41
42
43
44
45
46
47
48
package messaging
import (
"github.com/code-payments/code-server/pkg/config"
"github.com/code-payments/code-server/pkg/config/env"
"github.com/code-payments/code-server/pkg/config/memory"
"github.com/code-payments/code-server/pkg/config/wrapper"
)
const (
envConfigPrefix = "MESSAGING_SERVICE_"
DisableBlockchainChecksConfigEnvName = envConfigPrefix + "DISABLE_BLOCKCHAIN_CHECKS"
defaultDisableBlockchainChecks = false
MaxFeeBasisPointsConfigEnvName = envConfigPrefix + "MAX_FEE_BASIS_POINTS"
defaultMaxFeeBasisPoints = 5000
)
type conf struct {
disableBlockchainChecks config.Bool
maxFeeBasisPoints config.Uint64
}
// ConfigProvider defines how config values are pulled
type ConfigProvider func() *conf
// WithEnvConfigs returns configuration pulled from environment variables
func WithEnvConfigs() ConfigProvider {
return func() *conf {
return &conf{
disableBlockchainChecks: env.NewBoolConfig(DisableBlockchainChecksConfigEnvName, defaultDisableBlockchainChecks),
maxFeeBasisPoints: env.NewUint64Config(MaxFeeBasisPointsConfigEnvName, defaultMaxFeeBasisPoints),
}
}
}
type testOverrides struct {
}
func withManualTestOverrides(overrides *testOverrides) ConfigProvider {
return func() *conf {
return &conf{
disableBlockchainChecks: wrapper.NewBoolConfig(memory.NewConfig(true), true),
maxFeeBasisPoints: wrapper.NewUint64Config(memory.NewConfig(defaultMaxFeeBasisPoints), defaultMaxFeeBasisPoints),
}
}
}