init default stuff

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-09-07 13:38:52 +03:00
parent e7d418183b
commit 5fe3a46732
2 changed files with 27 additions and 0 deletions

View File

@ -53,12 +53,15 @@ type Options struct {
func NewOptions() Options {
return Options{
Auth: auth.DefaultAuth,
Codecs: make(map[string]codec.NewCodec),
Context: context.Background(),
Metadata: map[string]string{},
RegisterInterval: DefaultRegisterInterval,
RegisterTTL: DefaultRegisterTTL,
RegisterCheck: DefaultRegisterCheck,
Broker: broker.DefaultBroker,
Registry: registry.DefaultRegistry,
Address: DefaultAddress,
Name: DefaultName,
Version: DefaultVersion,

View File

@ -64,6 +64,30 @@ func (s *service) Init(opts ...Option) {
logger.Fatalf("[cmd] init failed: %v", err)
}
if err := s.opts.Registry.Init(); err != nil {
logger.Fatalf("[cmd] init failed: %v", err)
}
if err := s.opts.Broker.Init(); err != nil {
logger.Fatalf("[cmd] init failed: %v", err)
}
if err := s.opts.Transport.Init(); err != nil {
logger.Fatalf("[cmd] init failed: %v", err)
}
if err := s.opts.Store.Init(); err != nil {
logger.Fatalf("[cmd] init failed: %v", err)
}
if err := s.opts.Server.Init(); err != nil {
logger.Fatalf("[cmd] init failed: %v", err)
}
if err := s.opts.Client.Init(); err != nil {
logger.Fatalf("[cmd] init failed: %v", err)
}
// execute the command
// TODO: do this in service.Run()
if err := s.opts.Cmd.Run(); err != nil {