service: config load only on start, not init phase
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
c10f29ee74
commit
575af66ddc
@ -29,10 +29,10 @@ type record struct {
|
||||
}
|
||||
|
||||
type memory struct {
|
||||
sync.RWMutex
|
||||
records map[string]services
|
||||
watchers map[string]*watcher
|
||||
opts Options
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
// services is a KV map with service name as the key and a map of records as the value
|
||||
|
@ -12,10 +12,9 @@ import (
|
||||
|
||||
// Resolver is a DNS network resolve
|
||||
type Resolver struct {
|
||||
goresolver *net.Resolver
|
||||
// Address of resolver to use
|
||||
Address string
|
||||
sync.RWMutex
|
||||
goresolver *net.Resolver
|
||||
Address string
|
||||
}
|
||||
|
||||
// Resolve tries to resolve endpoint address
|
||||
@ -47,7 +46,7 @@ func (r *Resolver) Resolve(name string) ([]*resolver.Record, error) {
|
||||
if goresolver == nil {
|
||||
r.Lock()
|
||||
r.goresolver = &net.Resolver{
|
||||
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
Dial: func(ctx context.Context, _ string, _ string) (net.Conn, error) {
|
||||
d := net.Dialer{
|
||||
Timeout: time.Millisecond * time.Duration(100),
|
||||
}
|
||||
|
@ -36,11 +36,11 @@ type handler struct {
|
||||
type subscriber struct {
|
||||
typ reflect.Type
|
||||
subscriber interface{}
|
||||
rcvr reflect.Value
|
||||
topic string
|
||||
endpoints []*register.Endpoint
|
||||
handlers []*handler
|
||||
opts SubscriberOptions
|
||||
rcvr reflect.Value
|
||||
}
|
||||
|
||||
// Is this an exported - upper case - name?
|
||||
|
@ -73,9 +73,8 @@ func RegisterSubscriber(topic string, s server.Server, h interface{}, opts ...se
|
||||
}
|
||||
|
||||
type service struct {
|
||||
opts Options
|
||||
sync.RWMutex
|
||||
// once sync.Once
|
||||
opts Options
|
||||
}
|
||||
|
||||
// NewService creates and returns a new Service based on the packages within.
|
||||
@ -108,11 +107,6 @@ func (s *service) Init(opts ...Option) error {
|
||||
if err = cfg.Init(config.Context(cfg.Options().Context)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = cfg.Load(cfg.Options().Context); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for _, log := range s.opts.Loggers {
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
)
|
||||
|
||||
type memorySync struct {
|
||||
mtx gosync.RWMutex
|
||||
locks map[string]*memoryLock
|
||||
options Options
|
||||
mtx gosync.RWMutex
|
||||
}
|
||||
|
||||
type memoryLock struct {
|
||||
|
@ -10,16 +10,16 @@ import (
|
||||
|
||||
// Buffer is ring buffer
|
||||
type Buffer struct {
|
||||
sync.RWMutex
|
||||
streams map[string]*Stream
|
||||
vals []*Entry
|
||||
size int
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
// Entry is ring buffer data entry
|
||||
type Entry struct {
|
||||
Value interface{}
|
||||
Timestamp time.Time
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
// Stream is used to stream the buffer
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
|
||||
// Pool holds the socket pool
|
||||
type Pool struct {
|
||||
pool map[string]*Socket
|
||||
sync.RWMutex
|
||||
pool map[string]*Socket
|
||||
}
|
||||
|
||||
// Get socket from pool
|
||||
|
@ -20,10 +20,10 @@ type Stream interface {
|
||||
}
|
||||
|
||||
type stream struct {
|
||||
sync.RWMutex
|
||||
Stream
|
||||
err error
|
||||
request *request
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
type request struct {
|
||||
|
Loading…
Reference in New Issue
Block a user