feat: registry.
This commit is contained in:
35
registry/etcd/options.go
Normal file
35
registry/etcd/options.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package etcd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Option is etcd registry option.
|
||||
type Option func(o *options)
|
||||
|
||||
type options struct {
|
||||
ctx context.Context
|
||||
namespace string
|
||||
ttl time.Duration
|
||||
maxRetry int
|
||||
}
|
||||
|
||||
// Context with registry context.
|
||||
func Context(ctx context.Context) Option {
|
||||
return func(o *options) { o.ctx = ctx }
|
||||
}
|
||||
|
||||
// Namespace with registry namespace.
|
||||
func Namespace(ns string) Option {
|
||||
return func(o *options) { o.namespace = ns }
|
||||
}
|
||||
|
||||
// RegisterTTL with register ttl.
|
||||
func RegisterTTL(ttl time.Duration) Option {
|
||||
return func(o *options) { o.ttl = ttl }
|
||||
}
|
||||
|
||||
func MaxRetry(num int) Option {
|
||||
return func(o *options) { o.maxRetry = num }
|
||||
}
|
||||
Reference in New Issue
Block a user