From 1c5a4c470f267a29461bb2289d269ae22e92f1d4 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 5 Dec 2019 19:37:03 +0300 Subject: [PATCH] add server Context option to pass own context Signed-off-by: Vasiliy Tolstov --- server/options.go | 9 +++++++++ web/options.go | 3 +++ 2 files changed, 12 insertions(+) diff --git a/server/options.go b/server/options.go index 110699ae..cbced938 100644 --- a/server/options.go +++ b/server/options.go @@ -136,6 +136,15 @@ func Codec(contentType string, c codec.NewCodec) Option { } } +// Context specifies a context for the service. +// Can be used to signal shutdown of the service +// Can be used for extra option values. +func Context(ctx context.Context) Option { + return func(o *Options) { + o.Context = ctx + } +} + // Registry used for discovery func Registry(r registry.Registry) Option { return func(o *Options) { diff --git a/web/options.go b/web/options.go index 9a31f6d0..05f7f615 100644 --- a/web/options.go +++ b/web/options.go @@ -126,18 +126,21 @@ func Context(ctx context.Context) Option { } } +// Registry used for discovery func Registry(r registry.Registry) Option { return func(o *Options) { o.Registry = r } } +// Register the service with a TTL func RegisterTTL(t time.Duration) Option { return func(o *Options) { o.RegisterTTL = t } } +// Register the service with at interval func RegisterInterval(t time.Duration) Option { return func(o *Options) { o.RegisterInterval = t