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