Prefer RegisterTTL set through Init
This commit is contained in:
@@ -26,6 +26,8 @@ type Options struct {
|
||||
HdlrWrappers []HandlerWrapper
|
||||
SubWrappers []SubscriberWrapper
|
||||
|
||||
RegisterTTL time.Duration
|
||||
|
||||
// Debug Handler which can be set by a user
|
||||
DebugHandler debug.DebugHandler
|
||||
|
||||
@@ -34,10 +36,6 @@ type Options struct {
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
type RegisterOptions struct {
|
||||
TTL time.Duration
|
||||
}
|
||||
|
||||
func newOptions(opt ...Option) Options {
|
||||
opts := Options{
|
||||
Codecs: make(map[string]codec.NewCodec),
|
||||
@@ -160,6 +158,13 @@ func Metadata(md map[string]string) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// Register the service with a TTL
|
||||
func RegisterTTL(t time.Duration) Option {
|
||||
return func(o *Options) {
|
||||
o.RegisterTTL = t
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a handler Wrapper to a list of options passed into the server
|
||||
func WrapHandler(w HandlerWrapper) Option {
|
||||
return func(o *Options) {
|
||||
@@ -173,10 +178,3 @@ func WrapSubscriber(w SubscriberWrapper) Option {
|
||||
o.SubWrappers = append(o.SubWrappers, w)
|
||||
}
|
||||
}
|
||||
|
||||
// Register the service with a TTL
|
||||
func RegisterTTL(t time.Duration) RegisterOption {
|
||||
return func(o *RegisterOptions) {
|
||||
o.TTL = t
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user