service init with own context

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-03-28 23:42:02 +03:00
parent 9830cb48a9
commit 52d8255974
2 changed files with 9 additions and 8 deletions

1
go.sum
View File

@ -10,6 +10,7 @@ github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaR
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/silas/dag v0.0.0-20210121180416-41cf55125c34 h1:vBfVmA5mZhsQa2jr1FOL9nfA37N/jnbBmi5XUfviVTI= github.com/silas/dag v0.0.0-20210121180416-41cf55125c34 h1:vBfVmA5mZhsQa2jr1FOL9nfA37N/jnbBmi5XUfviVTI=
github.com/silas/dag v0.0.0-20210121180416-41cf55125c34/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I= github.com/silas/dag v0.0.0-20210121180416-41cf55125c34/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I=
golang.org/x/net v0.0.0-20210326220855-61e056675ecf h1:WUcCxqQqDT0aXO4VnQbfMvp4zh7m1Gb2clVuHUAGGRE=
golang.org/x/net v0.0.0-20210326220855-61e056675ecf/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20210326220855-61e056675ecf/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

View File

@ -103,48 +103,48 @@ func (s *service) Init(opts ...Option) error {
// skip config as the struct not passed // skip config as the struct not passed
continue continue
} }
if err = cfg.Init(config.Context(s.opts.Context)); err != nil { if err = cfg.Init(config.Context(cfg.Options().Context)); err != nil {
return err return err
} }
if err = cfg.Load(s.opts.Context); err != nil { if err = cfg.Load(cfg.Options().Context); err != nil {
return err return err
} }
} }
for _, log := range s.opts.Loggers { for _, log := range s.opts.Loggers {
if err = log.Init(logger.WithContext(s.opts.Context)); err != nil { if err = log.Init(logger.WithContext(log.Options().Context)); err != nil {
return err return err
} }
} }
for _, reg := range s.opts.Registers { for _, reg := range s.opts.Registers {
if err = reg.Init(register.Context(s.opts.Context)); err != nil { if err = reg.Init(register.Context(reg.Options().Context)); err != nil {
return err return err
} }
} }
for _, brk := range s.opts.Brokers { for _, brk := range s.opts.Brokers {
if err = brk.Init(broker.Context(s.opts.Context)); err != nil { if err = brk.Init(broker.Context(brk.Options().Context)); err != nil {
return err return err
} }
} }
for _, str := range s.opts.Stores { for _, str := range s.opts.Stores {
if err = str.Init(store.Context(s.opts.Context)); err != nil { if err = str.Init(store.Context(str.Options().Context)); err != nil {
return err return err
} }
} }
for _, srv := range s.opts.Servers { for _, srv := range s.opts.Servers {
if err = srv.Init(server.Context(s.opts.Context)); err != nil { if err = srv.Init(server.Context(srv.Options().Context)); err != nil {
return err return err
} }
} }
for _, cli := range s.opts.Clients { for _, cli := range s.opts.Clients {
if err = cli.Init(client.Context(s.opts.Context)); err != nil { if err = cli.Init(client.Context(cli.Options().Context)); err != nil {
return err return err
} }
} }