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
2021-10-12 12:55:53 +01:00

41 lines
872 B
Go

package grpc
import (
"context"
"crypto/tls"
"go-micro.dev/v4/config/source"
)
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)
}
}