1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-05-19 21:23:04 +02:00

38 lines
784 B
Go
Raw Normal View History

2020-12-26 15:32:45 +00:00
package etcd
import (
2020-12-29 15:49:26 +00:00
"context"
2021-10-12 12:55:53 +01:00
"go-micro.dev/v4/registry"
2020-12-29 15:49:26 +00:00
"go.uber.org/zap"
2020-12-26 15:32:45 +00:00
)
2020-12-29 15:49:26 +00:00
type authKey struct{}
type logConfigKey struct{}
type authCreds struct {
Username string
Password string
}
2020-12-26 15:32:45 +00:00
// Auth allows you to specify username/password
func Auth(username, password string) registry.Option {
2020-12-29 15:49:26 +00:00
return func(o *registry.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, authKey{}, &authCreds{Username: username, Password: password})
}
}
// LogConfig allows you to set etcd log config
func LogConfig(config *zap.Config) registry.Option {
return func(o *registry.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, logConfigKey{}, config)
}
2020-12-26 15:32:45 +00:00
}