Add store to options (#1600)
This commit is contained in:
parent
08a2de1ef5
commit
b3915b6020
@ -118,6 +118,12 @@ func Server(s *server.Server) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Store(s *store.Store) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.Store = s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Tracer(t *trace.Tracer) Option {
|
func Tracer(t *trace.Tracer) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Tracer = t
|
o.Tracer = t
|
||||||
|
10
options.go
10
options.go
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/micro/go-micro/v2/debug/trace"
|
"github.com/micro/go-micro/v2/debug/trace"
|
||||||
"github.com/micro/go-micro/v2/registry"
|
"github.com/micro/go-micro/v2/registry"
|
||||||
"github.com/micro/go-micro/v2/server"
|
"github.com/micro/go-micro/v2/server"
|
||||||
|
"github.com/micro/go-micro/v2/store"
|
||||||
"github.com/micro/go-micro/v2/transport"
|
"github.com/micro/go-micro/v2/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -26,6 +27,7 @@ type Options struct {
|
|||||||
Config config.Config
|
Config config.Config
|
||||||
Client client.Client
|
Client client.Client
|
||||||
Server server.Server
|
Server server.Server
|
||||||
|
Store store.Store
|
||||||
Registry registry.Registry
|
Registry registry.Registry
|
||||||
Transport transport.Transport
|
Transport transport.Transport
|
||||||
Profile profile.Profile
|
Profile profile.Profile
|
||||||
@ -51,6 +53,7 @@ func newOptions(opts ...Option) Options {
|
|||||||
Config: config.DefaultConfig,
|
Config: config.DefaultConfig,
|
||||||
Client: client.DefaultClient,
|
Client: client.DefaultClient,
|
||||||
Server: server.DefaultServer,
|
Server: server.DefaultServer,
|
||||||
|
Store: store.DefaultStore,
|
||||||
Registry: registry.DefaultRegistry,
|
Registry: registry.DefaultRegistry,
|
||||||
Transport: transport.DefaultTransport,
|
Transport: transport.DefaultTransport,
|
||||||
Context: context.Background(),
|
Context: context.Background(),
|
||||||
@ -118,6 +121,13 @@ func Server(s server.Server) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store sets the store to use
|
||||||
|
func Store(s store.Store) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.Store = s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Registry sets the registry for the service
|
// Registry sets the registry for the service
|
||||||
// and the underlying components
|
// and the underlying components
|
||||||
func Registry(r registry.Registry) Option {
|
func Registry(r registry.Registry) Option {
|
||||||
|
@ -102,6 +102,7 @@ func (s *service) Init(opts ...Option) {
|
|||||||
cmd.Client(&s.opts.Client),
|
cmd.Client(&s.opts.Client),
|
||||||
cmd.Config(&s.opts.Config),
|
cmd.Config(&s.opts.Config),
|
||||||
cmd.Server(&s.opts.Server),
|
cmd.Server(&s.opts.Server),
|
||||||
|
cmd.Store(&s.opts.Store),
|
||||||
cmd.Profile(&s.opts.Profile),
|
cmd.Profile(&s.opts.Profile),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
logger.Fatal(err)
|
logger.Fatal(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user