micro/registry/options.go

60 lines
1017 B
Go
Raw Normal View History

2015-12-19 18:28:08 +00:00
package registry
import (
2016-01-16 23:39:47 +00:00
"crypto/tls"
2015-12-19 18:28:08 +00:00
"time"
"golang.org/x/net/context"
2015-12-19 18:28:08 +00:00
)
type Options struct {
2016-03-15 22:20:21 +00:00
Addrs []string
2016-01-16 23:39:47 +00:00
Timeout time.Duration
Secure bool
TLSConfig *tls.Config
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
2015-12-19 18:28:08 +00:00
}
2016-01-26 23:32:27 +00:00
type RegisterOptions struct {
TTL time.Duration
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
}
2016-03-15 22:20:21 +00:00
// Addrs is the registry addresses to use
func Addrs(addrs ...string) Option {
return func(o *Options) {
o.Addrs = addrs
}
}
2015-12-19 18:28:08 +00:00
func Timeout(t time.Duration) Option {
return func(o *Options) {
o.Timeout = t
}
}
2016-01-16 20:25:18 +00:00
// Secure communication with the registry
func Secure(b bool) Option {
return func(o *Options) {
o.Secure = b
}
}
2016-01-16 23:39:47 +00:00
// Specify TLS Config
func TLSConfig(t *tls.Config) Option {
return func(o *Options) {
o.TLSConfig = t
}
}
2016-01-26 23:32:27 +00:00
2016-01-27 12:23:18 +00:00
func RegisterTTL(t time.Duration) RegisterOption {
2016-01-26 23:32:27 +00:00
return func(o *RegisterOptions) {
o.TTL = t
}
}