-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
namesys/pubsub: publisher and resolver
Commits: namesys: pubsub Publisher and Resolver namesys/pubsub: pacify code climate. namesys/pubsub: timeout for rendezvous namesys/pubsub: filter self in bootstrap connections namesys/pubsub: Publish to the correct topic License: MIT Signed-off-by: vyzo <vyzo@hackzen.org> namesys/pubsub: unit test Commits: namesys/pubsub: test namesys/pubsub_test: pacify code climate namesys/pubsub: update test to use extant mock routing License: MIT Signed-off-by: vyzo <vyzo@hackzen.org> namesys/pubsub: integrate namesys pubsub namesys: integrate pubsub resolvers namesys/pubsub_test: tweak delays - trying to make travis happy. namesys/pubsub: fix duplicate bootstraps - subscription key is topic, not ipnskey. namesys/pubsub: no warning needed on cancellation namesys/pubsub: warning for receive errors - and more informative error messages at that. namesys/pubsub_test: smaller test - make it work with seemingly low fdlimits in travis/macosx. also, more informative test failures. namesys/pubsub: add delay to let pubsub perform handshake namesys/pubsub: update gx imports namesys/pubsub_test: preconnect publisher, reduce delays - preconnects the publisher to the receivers in order to avoid bootstrap flakiness with connectivity problems in travis. reduces sleeps to 1s for flood propagation (3s seems excessive with 5 hosts). namesys/pubsub: drop named return values in resolveOnce - per review comment. namesys/pubsub: check errors namesys/pubsub: store bytes in resolver datastore namesys/pubsub: resolver Cancel - for canceling subscriptions, pre whyrusleeping's request. namesys/pubsub: fix resolution without /ipns prefix - also improve the logging a bit. namesys/pubsub: don't resolve own keys through pubsub namesys/pubsub: signal ErrResolveFailed on resolution failure namesys/pubsub: use sync datastore, resolver lock only for subs namesys/pubsub_test: coverage for Cancel License: MIT Signed-off-by: vyzo <vyzo@hackzen.org> namesys/pubsub: parallelize dht and pubsub publishing Commits: namesys/pubsub: code cosmetics namesys: parallelize publishing with dht and pubsub namesys/pubsub: periodically reprovide topic rendezvous namesys/pubsub: cancelation for rendezvous goroutine namesys/pubsub: log ipns record seqno on publish License: MIT Signed-off-by: vyzo <vyzo@hackzen.org> namesys/pubsub: error checking License: MIT Signed-off-by: vyzo <vyzo@hackzen.org> namesys/pubsub: --enable-namesys-pubsub option and management Commits: package.json: update go-libp2p-blankhost namesys: fix stale package imports update go-testutil namesys/pubsub: reduce bootstrap provide period to 8hr namesys/pubsub: try to extract the key from id first option to enable ipns pubsub: --enable-namesys-pubsub ipfs name pubsub management subcommands corehttp/gateway_test: mockNamesys needs to implement GetResolver pacify code climate License: MIT Signed-off-by: vyzo <vyzo@hackzen.org> namesys/pubsub: pubsub sharness test test/sharness: test for ipns pubsub namesys/pubsub: return boolean indicator on Cancel package.json: remove duplicate entry for go-testutil update gx deps, testutil to 1.1.12 fix jenkins failure: use tabs in t0183-namesys-pubsub t0183: use 4 spaces for tabification License: MIT Signed-off-by: vyzo <vyzo@hackzen.org> namesys/pubsub: update for new command interface License: MIT Signed-off-by: vyzo <vyzo@hackzen.org> namesys/pubsub: fix sharness test for broken MacOS echo echo -n "" should print -n, but hey it's a mac. License: MIT Signed-off-by: vyzo <vyzo@hackzen.org>
- Loading branch information
1 parent
b18b1e9
commit e45df72
Showing
13 changed files
with
1,008 additions
and
26 deletions.
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
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
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,163 @@ | ||
package commands | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io" | ||
"strings" | ||
|
||
cmds "github.com/ipfs/go-ipfs/commands" | ||
e "github.com/ipfs/go-ipfs/core/commands/e" | ||
ns "github.com/ipfs/go-ipfs/namesys" | ||
|
||
cmdkit "gx/ipfs/QmUyfy4QSr3NXym4etEiRyxBLqqAeKHJuRdi8AACxg63fZ/go-ipfs-cmdkit" | ||
) | ||
|
||
type ipnsPubsubState struct { | ||
Enabled bool | ||
} | ||
|
||
type ipnsPubsubCancel struct { | ||
Canceled bool | ||
} | ||
|
||
// IpnsPubsubCmd is the subcommand that allows us to manage the IPNS pubsub system | ||
var IpnsPubsubCmd = &cmds.Command{ | ||
Helptext: cmdkit.HelpText{ | ||
Tagline: "IPNS pubsub management", | ||
ShortDescription: ` | ||
Manage and inspect the state of the IPNS pubsub resolver. | ||
Note: this command is experimental and subject to change as the system is refined | ||
`, | ||
}, | ||
Subcommands: map[string]*cmds.Command{ | ||
"state": ipnspsStateCmd, | ||
"subs": ipnspsSubsCmd, | ||
"cancel": ipnspsCancelCmd, | ||
}, | ||
} | ||
|
||
var ipnspsStateCmd = &cmds.Command{ | ||
Helptext: cmdkit.HelpText{ | ||
Tagline: "Query the state of IPNS pubsub", | ||
}, | ||
Run: func(req cmds.Request, res cmds.Response) { | ||
n, err := req.InvocContext().GetNode() | ||
if err != nil { | ||
res.SetError(err, cmdkit.ErrNormal) | ||
return | ||
} | ||
|
||
_, ok := n.Namesys.GetResolver("pubsub") | ||
res.SetOutput(&ipnsPubsubState{ok}) | ||
}, | ||
Type: ipnsPubsubState{}, | ||
Marshalers: cmds.MarshalerMap{ | ||
cmds.Text: func(res cmds.Response) (io.Reader, error) { | ||
v, err := unwrapOutput(res.Output()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
output, ok := v.(*ipnsPubsubState) | ||
if !ok { | ||
return nil, e.TypeErr(output, v) | ||
} | ||
|
||
var state string | ||
if output.Enabled { | ||
state = "enabled" | ||
} else { | ||
state = "disabled" | ||
} | ||
|
||
return strings.NewReader(state + "\n"), nil | ||
}, | ||
}, | ||
} | ||
|
||
var ipnspsSubsCmd = &cmds.Command{ | ||
Helptext: cmdkit.HelpText{ | ||
Tagline: "Show current name subscriptions", | ||
}, | ||
Run: func(req cmds.Request, res cmds.Response) { | ||
n, err := req.InvocContext().GetNode() | ||
if err != nil { | ||
res.SetError(err, cmdkit.ErrNormal) | ||
return | ||
} | ||
|
||
r, ok := n.Namesys.GetResolver("pubsub") | ||
if !ok { | ||
res.SetError(errors.New("IPNS pubsub subsystem is not enabled"), cmdkit.ErrClient) | ||
return | ||
} | ||
|
||
psr, ok := r.(*ns.PubsubResolver) | ||
if !ok { | ||
res.SetError(fmt.Errorf("unexpected resolver type: %v", r), cmdkit.ErrNormal) | ||
return | ||
} | ||
|
||
res.SetOutput(&stringList{psr.GetSubscriptions()}) | ||
}, | ||
Type: stringList{}, | ||
Marshalers: cmds.MarshalerMap{ | ||
cmds.Text: stringListMarshaler, | ||
}, | ||
} | ||
|
||
var ipnspsCancelCmd = &cmds.Command{ | ||
Helptext: cmdkit.HelpText{ | ||
Tagline: "Cancel a name subscription", | ||
}, | ||
Run: func(req cmds.Request, res cmds.Response) { | ||
n, err := req.InvocContext().GetNode() | ||
if err != nil { | ||
res.SetError(err, cmdkit.ErrNormal) | ||
return | ||
} | ||
|
||
r, ok := n.Namesys.GetResolver("pubsub") | ||
if !ok { | ||
res.SetError(errors.New("IPNS pubsub subsystem is not enabled"), cmdkit.ErrClient) | ||
return | ||
} | ||
|
||
psr, ok := r.(*ns.PubsubResolver) | ||
if !ok { | ||
res.SetError(fmt.Errorf("unexpected resolver type: %v", r), cmdkit.ErrNormal) | ||
return | ||
} | ||
|
||
ok = psr.Cancel(req.Arguments()[0]) | ||
res.SetOutput(&ipnsPubsubCancel{ok}) | ||
}, | ||
Arguments: []cmdkit.Argument{ | ||
cmdkit.StringArg("name", true, false, "Name to cancel the subscription for."), | ||
}, | ||
Type: ipnsPubsubCancel{}, | ||
Marshalers: cmds.MarshalerMap{ | ||
cmds.Text: func(res cmds.Response) (io.Reader, error) { | ||
v, err := unwrapOutput(res.Output()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
output, ok := v.(*ipnsPubsubCancel) | ||
if !ok { | ||
return nil, e.TypeErr(output, v) | ||
} | ||
|
||
var state string | ||
if output.Canceled { | ||
state = "canceled" | ||
} else { | ||
state = "no subscription" | ||
} | ||
|
||
return strings.NewReader(state + "\n"), 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
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
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
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
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
Oops, something went wrong.