|
|
|
@ -27,6 +27,9 @@ type options struct { |
|
|
|
|
registrar registry.Registrar |
|
|
|
|
|
|
|
|
|
servers []transport.Server |
|
|
|
|
|
|
|
|
|
before []func() error |
|
|
|
|
after []func() error |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ID with service id.
|
|
|
|
@ -78,3 +81,13 @@ func Registry(r registry.Registrar) Option { |
|
|
|
|
func Server(srv ...transport.Server) Option { |
|
|
|
|
return func(o *options) { o.servers = srv } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Before before service starts.
|
|
|
|
|
func Before(fn func() error) Option { |
|
|
|
|
return func(o *options) { o.before = append(o.before, fn) } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// After after services stops.
|
|
|
|
|
func After(fn func() error) Option { |
|
|
|
|
return func(o *options) { o.after = append(o.after, fn) } |
|
|
|
|
} |
|
|
|
|