Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
0ad4722d
Commit
0ad4722d
authored
Oct 04, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coreapi name: add some missing options
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
713de024
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
options/name.go
options/name.go
+24
-0
No files found.
options/name.go
View file @
0ad4722d
...
@@ -13,6 +13,10 @@ const (
...
@@ -13,6 +13,10 @@ const (
type
NamePublishSettings
struct
{
type
NamePublishSettings
struct
{
ValidTime
time
.
Duration
ValidTime
time
.
Duration
Key
string
Key
string
TTL
*
time
.
Duration
AllowOffline
bool
}
}
type
NameResolveSettings
struct
{
type
NameResolveSettings
struct
{
...
@@ -29,6 +33,8 @@ func NamePublishOptions(opts ...NamePublishOption) (*NamePublishSettings, error)
...
@@ -29,6 +33,8 @@ func NamePublishOptions(opts ...NamePublishOption) (*NamePublishSettings, error)
options
:=
&
NamePublishSettings
{
options
:=
&
NamePublishSettings
{
ValidTime
:
DefaultNameValidTime
,
ValidTime
:
DefaultNameValidTime
,
Key
:
"self"
,
Key
:
"self"
,
AllowOffline
:
false
,
}
}
for
_
,
opt
:=
range
opts
{
for
_
,
opt
:=
range
opts
{
...
@@ -82,6 +88,24 @@ func (nameOpts) Key(key string) NamePublishOption {
...
@@ -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
// Local is an option for Name.Resolve which specifies if the lookup should be
// offline. Default value is false
// offline. Default value is false
func
(
nameOpts
)
Local
(
local
bool
)
NameResolveOption
{
func
(
nameOpts
)
Local
(
local
bool
)
NameResolveOption
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment