more lint fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
		| @@ -9,8 +9,11 @@ import ( | |||||||
| 	"github.com/unistack-org/micro/v3/store" | 	"github.com/unistack-org/micro/v3/store" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // NewOptions creates Options struct from slice of options | ||||||
| func NewOptions(opts ...Option) Options { | func NewOptions(opts ...Option) Options { | ||||||
| 	var options Options | 	options := Options{ | ||||||
|  | 		Logger: logger.DefaultLogger, | ||||||
|  | 	} | ||||||
| 	for _, o := range opts { | 	for _, o := range opts { | ||||||
| 		o(&options) | 		o(&options) | ||||||
| 	} | 	} | ||||||
| @@ -42,6 +45,7 @@ type Options struct { | |||||||
| 	Context context.Context | 	Context context.Context | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Option func | ||||||
| type Option func(o *Options) | type Option func(o *Options) | ||||||
|  |  | ||||||
| // Addrs is the auth addresses to use | // Addrs is the auth addresses to use | ||||||
| @@ -101,6 +105,7 @@ func LoginURL(url string) Option { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // GenerateOptions struct | ||||||
| type GenerateOptions struct { | type GenerateOptions struct { | ||||||
| 	// Metadata associated with the account | 	// Metadata associated with the account | ||||||
| 	Metadata metadata.Metadata | 	Metadata metadata.Metadata | ||||||
| @@ -116,6 +121,7 @@ type GenerateOptions struct { | |||||||
| 	Issuer string | 	Issuer string | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // GenerateOption func | ||||||
| type GenerateOption func(o *GenerateOptions) | type GenerateOption func(o *GenerateOptions) | ||||||
|  |  | ||||||
| // WithSecret for the generated account | // WithSecret for the generated account | ||||||
| @@ -169,6 +175,7 @@ func NewGenerateOptions(opts ...GenerateOption) GenerateOptions { | |||||||
| 	return options | 	return options | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // TokenOptions struct | ||||||
| type TokenOptions struct { | type TokenOptions struct { | ||||||
| 	// ID for the account | 	// ID for the account | ||||||
| 	ID string | 	ID string | ||||||
| @@ -182,6 +189,7 @@ type TokenOptions struct { | |||||||
| 	Issuer string | 	Issuer string | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // TokenOption func | ||||||
| type TokenOption func(o *TokenOptions) | type TokenOption func(o *TokenOptions) | ||||||
|  |  | ||||||
| // WithExpiry for the token | // WithExpiry for the token | ||||||
| @@ -191,6 +199,7 @@ func WithExpiry(ex time.Duration) TokenOption { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // WithCredentials sets tye id and secret | ||||||
| func WithCredentials(id, secret string) TokenOption { | func WithCredentials(id, secret string) TokenOption { | ||||||
| 	return func(o *TokenOptions) { | 	return func(o *TokenOptions) { | ||||||
| 		o.ID = id | 		o.ID = id | ||||||
| @@ -198,12 +207,14 @@ func WithCredentials(id, secret string) TokenOption { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // WithToken sets the refresh token | ||||||
| func WithToken(rt string) TokenOption { | func WithToken(rt string) TokenOption { | ||||||
| 	return func(o *TokenOptions) { | 	return func(o *TokenOptions) { | ||||||
| 		o.RefreshToken = rt | 		o.RefreshToken = rt | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // WithTokenIssuer sets the token issuer option | ||||||
| func WithTokenIssuer(iss string) TokenOption { | func WithTokenIssuer(iss string) TokenOption { | ||||||
| 	return func(o *TokenOptions) { | 	return func(o *TokenOptions) { | ||||||
| 		o.Issuer = iss | 		o.Issuer = iss | ||||||
| @@ -225,39 +236,55 @@ func NewTokenOptions(opts ...TokenOption) TokenOptions { | |||||||
| 	return options | 	return options | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // VerifyOptions struct | ||||||
| type VerifyOptions struct { | type VerifyOptions struct { | ||||||
| 	Context   context.Context | 	Context   context.Context | ||||||
| 	Namespace string | 	Namespace string | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // VerifyOption func | ||||||
| type VerifyOption func(o *VerifyOptions) | type VerifyOption func(o *VerifyOptions) | ||||||
|  |  | ||||||
|  | // VerifyContext pass context to verify | ||||||
| func VerifyContext(ctx context.Context) VerifyOption { | func VerifyContext(ctx context.Context) VerifyOption { | ||||||
| 	return func(o *VerifyOptions) { | 	return func(o *VerifyOptions) { | ||||||
| 		o.Context = ctx | 		o.Context = ctx | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // VerifyNamespace sets thhe namespace for verify | ||||||
| func VerifyNamespace(ns string) VerifyOption { | func VerifyNamespace(ns string) VerifyOption { | ||||||
| 	return func(o *VerifyOptions) { | 	return func(o *VerifyOptions) { | ||||||
| 		o.Namespace = ns | 		o.Namespace = ns | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // RulesOptions struct | ||||||
| type RulesOptions struct { | type RulesOptions struct { | ||||||
| 	Context   context.Context | 	Context   context.Context | ||||||
| 	Namespace string | 	Namespace string | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // RulesOption func | ||||||
| type RulesOption func(o *RulesOptions) | type RulesOption func(o *RulesOptions) | ||||||
|  |  | ||||||
|  | // RulesContext pass rules context | ||||||
| func RulesContext(ctx context.Context) RulesOption { | func RulesContext(ctx context.Context) RulesOption { | ||||||
| 	return func(o *RulesOptions) { | 	return func(o *RulesOptions) { | ||||||
| 		o.Context = ctx | 		o.Context = ctx | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // RulesNamespace sets the rule namespace | ||||||
| func RulesNamespace(ns string) RulesOption { | func RulesNamespace(ns string) RulesOption { | ||||||
| 	return func(o *RulesOptions) { | 	return func(o *RulesOptions) { | ||||||
| 		o.Namespace = ns | 		o.Namespace = ns | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Logger sets the logger | ||||||
|  | func Logger(l logger.Logger) Option { | ||||||
|  | 	return func(o *Options) { | ||||||
|  | 		o.Logger = l | ||||||
|  | 	} | ||||||
|  | } | ||||||
|   | |||||||
| @@ -13,9 +13,11 @@ import ( | |||||||
| type Options struct { | type Options struct { | ||||||
| 	Addrs  []string | 	Addrs  []string | ||||||
| 	Secure bool | 	Secure bool | ||||||
|  |  | ||||||
|  | 	// Codec | ||||||
| 	Codec codec.Codec | 	Codec codec.Codec | ||||||
|  |  | ||||||
| 	// Logger | 	// Logger the logger | ||||||
| 	Logger logger.Logger | 	Logger logger.Logger | ||||||
| 	// Handler executed when errors occur processing messages | 	// Handler executed when errors occur processing messages | ||||||
| 	ErrorHandler Handler | 	ErrorHandler Handler | ||||||
|   | |||||||
| @@ -28,6 +28,7 @@ type Option func(o *Options) | |||||||
|  |  | ||||||
| func NewOptions(opts ...Option) Options { | func NewOptions(opts ...Option) Options { | ||||||
| 	options := Options{ | 	options := Options{ | ||||||
|  | 		Logger:  logger.DefaultLogger, | ||||||
| 		Context: context.Background(), | 		Context: context.Background(), | ||||||
| 	} | 	} | ||||||
| 	for _, o := range opts { | 	for _, o := range opts { | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ type Options struct { | |||||||
| 	TLSConfig *tls.Config | 	TLSConfig *tls.Config | ||||||
| 	// Timeout sets the timeout for Send/Recv | 	// Timeout sets the timeout for Send/Recv | ||||||
| 	Timeout time.Duration | 	Timeout time.Duration | ||||||
| 	// Logger | 	// Logger sets the logger | ||||||
| 	Logger logger.Logger | 	Logger logger.Logger | ||||||
| 	// Other options for implementations of the interface | 	// Other options for implementations of the interface | ||||||
| 	// can be stored in a context | 	// can be stored in a context | ||||||
|   | |||||||
| @@ -13,6 +13,8 @@ type Options struct { | |||||||
| 	Timeout   time.Duration | 	Timeout   time.Duration | ||||||
| 	Secure    bool | 	Secure    bool | ||||||
| 	TLSConfig *tls.Config | 	TLSConfig *tls.Config | ||||||
|  |  | ||||||
|  | 	// Logger imp | ||||||
| 	Logger logger.Logger | 	Logger logger.Logger | ||||||
| 	// Other options for implementations of the interface | 	// Other options for implementations of the interface | ||||||
| 	// can be stored in a context | 	// can be stored in a context | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ type Options struct { | |||||||
| 	Database string | 	Database string | ||||||
| 	// Table is analag for a table in database backends or a key prefix in KV backends | 	// Table is analag for a table in database backends or a key prefix in KV backends | ||||||
| 	Table string | 	Table string | ||||||
| 	// Logger | 	// Logger the logger | ||||||
| 	Logger logger.Logger | 	Logger logger.Logger | ||||||
| 	// Context should contain all implementation specific options, using context.WithValue. | 	// Context should contain all implementation specific options, using context.WithValue. | ||||||
| 	Context context.Context | 	Context context.Context | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| package tracer | package tracer | ||||||
|  |  | ||||||
|  | import "github.com/unistack-org/micro/v3/logger" | ||||||
|  |  | ||||||
| var ( | var ( | ||||||
| 	// DefaultSize of the buffer | 	// DefaultSize of the buffer | ||||||
| 	DefaultSize = 64 | 	DefaultSize = 64 | ||||||
| @@ -7,6 +9,8 @@ var ( | |||||||
|  |  | ||||||
| // Options struct | // Options struct | ||||||
| type Options struct { | type Options struct { | ||||||
|  | 	// Logger is the logger for messages | ||||||
|  | 	Logger logger.Logger | ||||||
| 	// Size is the size of ring buffer | 	// Size is the size of ring buffer | ||||||
| 	Size int | 	Size int | ||||||
| } | } | ||||||
| @@ -30,9 +34,17 @@ func ReadTrace(t string) ReadOption { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Logger sets the logger | ||||||
|  | func Logger(l logger.Logger) Option { | ||||||
|  | 	return func(o *Options) { | ||||||
|  | 		o.Logger = l | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| // NewOptions returns default options | // NewOptions returns default options | ||||||
| func NewOptions(opts ...Option) Options { | func NewOptions(opts ...Option) Options { | ||||||
| 	options := Options{ | 	options := Options{ | ||||||
|  | 		Logger: logger.DefaultLogger, | ||||||
| 		Size:   DefaultSize, | 		Size:   DefaultSize, | ||||||
| 	} | 	} | ||||||
| 	for _, o := range opts { | 	for _, o := range opts { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user