generated from ipfs/ipfs-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(routing): allow-offline with routing put
- Loading branch information
1 parent
a12deee
commit d5dc6ee
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package options | ||
|
||
type RoutingPutSettings struct { | ||
AllowOffline bool | ||
} | ||
|
||
type RoutingPutOption func(*RoutingPutSettings) error | ||
|
||
func RoutingPutOptions(opts ...RoutingPutOption) (*RoutingPutSettings, error) { | ||
options := &RoutingPutSettings{ | ||
AllowOffline: false, | ||
} | ||
|
||
for _, opt := range opts { | ||
err := opt(options) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return options, nil | ||
} | ||
|
||
type putOpts struct{} | ||
|
||
var Put putOpts | ||
|
||
// AllowOffline is an option for Routing.Put which specifies whether to allow | ||
// publishing when the node is offline. Default value is false | ||
func (putOpts) AllowOffline(allow bool) RoutingPutOption { | ||
return func(settings *RoutingPutSettings) error { | ||
settings.AllowOffline = allow | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters