From 125646d89b55bdcd07369e4e69885009e39bcb5a Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 29 Jan 2021 14:07:35 +0300 Subject: [PATCH] add Name func option Signed-off-by: Vasiliy Tolstov --- auth/options.go | 8 ++++++++ config/options.go | 8 ++++++++ logger/options.go | 8 ++++++++ meter/options.go | 7 +++++++ network/transport/options.go | 8 ++++++++ network/tunnel/options.go | 8 ++++++++ register/options.go | 7 +++++++ tracer/options.go | 7 +++++++ 8 files changed, 61 insertions(+) diff --git a/auth/options.go b/auth/options.go index 328d275a..906880ca 100644 --- a/auth/options.go +++ b/auth/options.go @@ -25,6 +25,7 @@ func NewOptions(opts ...Option) Options { } type Options struct { + Name string // Issuer of the service's account Issuer string // ID is the services auth ID @@ -63,6 +64,13 @@ func Addrs(addrs ...string) Option { } } +// Name sets the name +func Name(n string) Option { + return func(o *Options) { + o.Name = n + } +} + // Issuer of the services account func Issuer(i string) Option { return func(o *Options) { diff --git a/config/options.go b/config/options.go index 69b7a0e4..533c30cf 100644 --- a/config/options.go +++ b/config/options.go @@ -10,6 +10,7 @@ import ( ) type Options struct { + Name string AllowFail bool BeforeLoad []func(context.Context, Config) error AfterLoad []func(context.Context, Config) error @@ -116,3 +117,10 @@ func StructTag(name string) Option { o.StructTag = name } } + +// Name sets the name +func Name(n string) Option { + return func(o *Options) { + o.Name = n + } +} diff --git a/logger/options.go b/logger/options.go index d3b36e93..1b32f46a 100644 --- a/logger/options.go +++ b/logger/options.go @@ -11,6 +11,7 @@ type Option func(*Options) // Options holds logger options type Options struct { + Name string // The logging level the logger should log at. default is `InfoLevel` Level Level // fields to always be logged @@ -72,3 +73,10 @@ func WithContext(ctx context.Context) Option { o.Context = ctx } } + +// WithName sets the name +func withName(n string) Option { + return func(o *Options) { + o.Name = n + } +} diff --git a/meter/options.go b/meter/options.go index aa461bea..4410c016 100644 --- a/meter/options.go +++ b/meter/options.go @@ -93,3 +93,10 @@ func Label(key, val string) Option { o.Labels.vals = append(o.Labels.vals, val) } } + +// Name sets the name +func Name(n string) Option { + return func(o *Options) { + o.Name = n + } +} diff --git a/network/transport/options.go b/network/transport/options.go index 5b497c7d..69d524c3 100644 --- a/network/transport/options.go +++ b/network/transport/options.go @@ -12,6 +12,7 @@ import ( ) type Options struct { + Name string // Addrs is the list of intermediary addresses to connect to Addrs []string // Codec is the codec interface to use where headers are not supported @@ -176,3 +177,10 @@ func Tracer(t tracer.Tracer) Option { o.Tracer = t } } + +// Name sets the name +func Name(n string) Option { + return func(o *Options) { + o.Name = n + } +} diff --git a/network/tunnel/options.go b/network/tunnel/options.go index 788d69ba..a0a09c08 100644 --- a/network/tunnel/options.go +++ b/network/tunnel/options.go @@ -22,6 +22,7 @@ type Option func(*Options) // Options provides network configuration options type Options struct { + Name string // Id is tunnel id Id string // Address is tunnel address @@ -181,3 +182,10 @@ func Tracer(t tracer.Tracer) Option { o.Tracer = t } } + +// Name sets the name +func Name(n string) Option { + return func(o *Options) { + o.Name = n + } +} diff --git a/register/options.go b/register/options.go index fa906a2e..806db90c 100644 --- a/register/options.go +++ b/register/options.go @@ -269,3 +269,10 @@ func ListDomain(d string) ListOption { o.Domain = d } } + +// Name sets the name +func Name(n string) Option { + return func(o *Options) { + o.Name = n + } +} diff --git a/tracer/options.go b/tracer/options.go index 9a6b58b1..df7cc80e 100644 --- a/tracer/options.go +++ b/tracer/options.go @@ -53,3 +53,10 @@ func NewOptions(opts ...Option) Options { } return options } + +// Name sets the name +func Name(n string) Option { + return func(o *Options) { + o.Name = n + } +}