1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-05-19 21:23:04 +02:00
go-micro/registry/etcd/options.go
Brian Ketelsen cd2b40ca4a
Add a selection of plugins to the core repo (#2755)
* WIP

* fix: default memory registry, add registrations for mdns, nats

* fix: same for broker

* fix: add more

* fix: http port

* rename redis

* chore: linting
2025-05-15 18:47:35 +01:00

38 lines
786 B
Go

package etcd
import (
"context"
"go-micro.dev/v5/registry"
"go.uber.org/zap"
)
type authKey struct{}
type logConfigKey struct{}
type authCreds struct {
Username string
Password string
}
// Auth allows you to specify username/password.
func Auth(username, password string) registry.Option {
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)
}
}