From 5fe3a46732e7bbb36fd5612145d16fb9302fe8e6 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 7 Sep 2020 13:38:52 +0300 Subject: [PATCH] init default stuff Signed-off-by: Vasiliy Tolstov --- server/options.go | 3 +++ service.go | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/server/options.go b/server/options.go index 2c2bf0ab..60c1fcdd 100644 --- a/server/options.go +++ b/server/options.go @@ -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, diff --git a/service.go b/service.go index bb3c5f89..63fbad18 100644 --- a/service.go +++ b/service.go @@ -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 {