1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-12 08:23:58 +02:00
go-micro/plugins/config/source/grpc/options.go

41 lines
872 B
Go
Raw Normal View History

2020-12-26 17:32:45 +02:00
package grpc
import (
"context"
"crypto/tls"
2021-10-12 13:55:53 +02:00
"go-micro.dev/v4/config/source"
2020-12-26 17:32:45 +02:00
)
type addressKey struct{}
type pathKey struct{}
// WithAddress sets the consul address
func WithAddress(a string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, addressKey{}, a)
}
}
// WithPath sets the key prefix to use
func WithPath(p string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, pathKey{}, p)
}
}
// WithTLS sets the TLS config for the service
func WithTLS(t *tls.Config) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, tls.Config{}, t)
}
}