add Name func option

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-01-29 14:07:35 +03:00
parent 7af7649448
commit 125646d89b
8 changed files with 61 additions and 0 deletions

View File

@ -25,6 +25,7 @@ func NewOptions(opts ...Option) Options {
} }
type Options struct { type Options struct {
Name string
// Issuer of the service's account // Issuer of the service's account
Issuer string Issuer string
// ID is the services auth ID // 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 // Issuer of the services account
func Issuer(i string) Option { func Issuer(i string) Option {
return func(o *Options) { return func(o *Options) {

View File

@ -10,6 +10,7 @@ import (
) )
type Options struct { type Options struct {
Name string
AllowFail bool AllowFail bool
BeforeLoad []func(context.Context, Config) error BeforeLoad []func(context.Context, Config) error
AfterLoad []func(context.Context, Config) error AfterLoad []func(context.Context, Config) error
@ -116,3 +117,10 @@ func StructTag(name string) Option {
o.StructTag = name o.StructTag = name
} }
} }
// Name sets the name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}

View File

@ -11,6 +11,7 @@ type Option func(*Options)
// Options holds logger options // Options holds logger options
type Options struct { type Options struct {
Name string
// The logging level the logger should log at. default is `InfoLevel` // The logging level the logger should log at. default is `InfoLevel`
Level Level Level Level
// fields to always be logged // fields to always be logged
@ -72,3 +73,10 @@ func WithContext(ctx context.Context) Option {
o.Context = ctx o.Context = ctx
} }
} }
// WithName sets the name
func withName(n string) Option {
return func(o *Options) {
o.Name = n
}
}

View File

@ -93,3 +93,10 @@ func Label(key, val string) Option {
o.Labels.vals = append(o.Labels.vals, val) o.Labels.vals = append(o.Labels.vals, val)
} }
} }
// Name sets the name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}

View File

@ -12,6 +12,7 @@ import (
) )
type Options struct { type Options struct {
Name string
// Addrs is the list of intermediary addresses to connect to // Addrs is the list of intermediary addresses to connect to
Addrs []string Addrs []string
// Codec is the codec interface to use where headers are not supported // 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 o.Tracer = t
} }
} }
// Name sets the name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}

View File

@ -22,6 +22,7 @@ type Option func(*Options)
// Options provides network configuration options // Options provides network configuration options
type Options struct { type Options struct {
Name string
// Id is tunnel id // Id is tunnel id
Id string Id string
// Address is tunnel address // Address is tunnel address
@ -181,3 +182,10 @@ func Tracer(t tracer.Tracer) Option {
o.Tracer = t o.Tracer = t
} }
} }
// Name sets the name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}

View File

@ -269,3 +269,10 @@ func ListDomain(d string) ListOption {
o.Domain = d o.Domain = d
} }
} }
// Name sets the name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}

View File

@ -53,3 +53,10 @@ func NewOptions(opts ...Option) Options {
} }
return options return options
} }
// Name sets the name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}