Prefer RegisterTTL set through Init

This commit is contained in:
Asim
2016-01-27 12:23:18 +00:00
parent 61094fefe8
commit 013d1de2c4
6 changed files with 19 additions and 30 deletions

View File

@@ -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
}
}