-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
53 lines (39 loc) · 1.2 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
49
50
51
52
53
package registry
import (
"fmt"
"time"
"github.com/pubgo/funk/assert"
"github.com/pubgo/funk/errors"
)
// https://github.com/go-eagle/eagle/blob/master/pkg/registry/registry.go
const DefaultPrefix = "/registry"
var Name = "registry"
const (
// DefaultMaxMsgSize define maximum message size that server can send or receive.
// Default value is 4MB.
DefaultMaxMsgSize = 1024 * 1024 * 4
DefaultSleepAfterDeRegister = time.Second * 2
// DefaultRegisterTTL The register expiry time
DefaultRegisterTTL = time.Minute
// DefaultRegisterInterval The interval on which to register
DefaultRegisterInterval = time.Second * 30
defaultContentType = "application/grpc"
DefaultSleepAfterDeregister = time.Second * 2
)
type Config struct {
RegisterInterval time.Duration `yaml:"registerInterval"`
Driver string `json:"driver" yaml:"driver"`
DriverCfg map[string]interface{} `json:"driver_config" yaml:"driver_config"`
}
func (cfg *Config) Check() *Config {
assert.Fn(cfg.Driver == "", func() error {
err := fmt.Errorf("registry driver is null")
return errors.WrapKV(err, "cfg", cfg)
})
return cfg
}
func DefaultCfg() Config {
return Config{
Driver: "mdns",
}
}