mirror of
https://github.com/go-micro/go-micro.git
synced 2024-11-24 08:02:32 +02:00
60 lines
1017 B
Go
60 lines
1017 B
Go
package registry
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"time"
|
|
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
type Options struct {
|
|
Addrs []string
|
|
Timeout time.Duration
|
|
Secure bool
|
|
TLSConfig *tls.Config
|
|
|
|
// Other options for implementations of the interface
|
|
// can be stored in a context
|
|
Context context.Context
|
|
}
|
|
|
|
type RegisterOptions struct {
|
|
TTL time.Duration
|
|
// Other options for implementations of the interface
|
|
// can be stored in a context
|
|
Context context.Context
|
|
}
|
|
|
|
// Addrs is the registry addresses to use
|
|
func Addrs(addrs ...string) Option {
|
|
return func(o *Options) {
|
|
o.Addrs = addrs
|
|
}
|
|
}
|
|
|
|
func Timeout(t time.Duration) Option {
|
|
return func(o *Options) {
|
|
o.Timeout = t
|
|
}
|
|
}
|
|
|
|
// Secure communication with the registry
|
|
func Secure(b bool) Option {
|
|
return func(o *Options) {
|
|
o.Secure = b
|
|
}
|
|
}
|
|
|
|
// Specify TLS Config
|
|
func TLSConfig(t *tls.Config) Option {
|
|
return func(o *Options) {
|
|
o.TLSConfig = t
|
|
}
|
|
}
|
|
|
|
func RegisterTTL(t time.Duration) RegisterOption {
|
|
return func(o *RegisterOptions) {
|
|
o.TTL = t
|
|
}
|
|
}
|