Commit 0ad4722d authored by Łukasz Magiera's avatar Łukasz Magiera

coreapi name: add some missing options

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent 713de024
......@@ -13,6 +13,10 @@ const (
type NamePublishSettings struct {
ValidTime time.Duration
Key string
TTL *time.Duration
AllowOffline bool
}
type NameResolveSettings struct {
......@@ -29,6 +33,8 @@ func NamePublishOptions(opts ...NamePublishOption) (*NamePublishSettings, error)
options := &NamePublishSettings{
ValidTime: DefaultNameValidTime,
Key: "self",
AllowOffline: false,
}
for _, opt := range opts {
......@@ -82,6 +88,24 @@ func (nameOpts) Key(key string) NamePublishOption {
}
}
// AllowOffline is an option for Name.Publish which specifies whether to allow
// publishing when the node is offline. Default value is false
func (nameOpts) AllowOffline(allow bool) NamePublishOption {
return func(settings *NamePublishSettings) error {
settings.AllowOffline = allow
return nil
}
}
// TTL is an option for Name.Publish which specifies the time duration the
// published record should be cached for (caution: experimental).
func (nameOpts) TTL(ttl time.Duration) NamePublishOption {
return func(settings *NamePublishSettings) error {
settings.TTL = &ttl
return nil
}
}
// Local is an option for Name.Resolve which specifies if the lookup should be
// offline. Default value is false
func (nameOpts) Local(local bool) NameResolveOption {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment