Skip to content

Commit

Permalink
Use correct group.
Browse files Browse the repository at this point in the history
  • Loading branch information
afshin committed Jul 3, 2016
1 parent 9d761a6 commit 608a5e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ A complete tutorial based on that example can be found here: [Service autodiscov
**Q**: How does it work? I understand *what* `sleuth` does, but I want to know *how* it does it.

**A**: Services that instantiate a `sleuth.Client` create an *ad hoc* [`Gyre`](https://github.com/zeromq/gyre) network. `Gyre` is the Go port of the [`Zyre`](https://github.com/zeromq/zyre) project, which is built on top of [ØMQ](https://github.com/zeromq/libzmq) (ZeroMQ). Nodes in the network discover each other using a UDP beacon on port `5670`. The actual communication between nodes happens on ephemeral `TCP` connections. What `sleuth` does is to manage this life cycle:
* A peer joins the `Gyre` network as a member of the group `SLEUTH-v0`. If the peer offers a service, *i.e.*, if it has an [`http.Handler`](https://golang.org/pkg/net/http/#Handler), it notifies the rest of the network when it announces itself. The peer might have no service to offer, thus operating in client-only mode, or it may offer *one* service.
* A peer joins the `Gyre` network as a member of the group `SLEUTH-v1`. If the peer offers a service, *i.e.*, if it has an [`http.Handler`](https://golang.org/pkg/net/http/#Handler), it notifies the rest of the network when it announces itself. The peer might have no service to offer, thus operating in client-only mode, or it may offer *one* service.
* The peer finds other peers on the network. If you have asked the `sleuth` client to [`WaitFor()`](https://godoc.org/github.com/ursiform/sleuth#Client.WaitFor) one or more services to appear before continuing, that call will block until it has found those services.
* If the peer is offering a service, `sleuth` automatically listens for incoming requests in a separate goroutine and responds to incoming requests by invoking the [`http.Handler`](https://golang.org/pkg/net/http/#Handler) that was passed in during instantiation.
* When you make a request to an available service, `sleuth` marshals the request, sends it to one of the available peers that offers that service, and waits for a response. If the response succeeds, it returns an [`http.Response`](https://golang.org/pkg/net/http/#Response); if it times out, it returns an error. The `sleuth` client [`Do()`](https://godoc.org/github.com/ursiform/sleuth#Client.Do) method has the same signature as the `http` client [`Do()`](https://golang.org/pkg/net/http/#Client.Do) method in order to operate as a drop-in replacement.
Expand Down
6 changes: 3 additions & 3 deletions sleuth.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

const (
group = "SLEUTH-v0"
group = "SLEUTH-v1"
port = 5670
recv = "RECV"
repl = "REPL"
Expand Down Expand Up @@ -91,7 +91,7 @@ func newNode(conn *connection, log *logger.Logger) (*gyre.Gyre, error) {
if err := node.Start(); err != nil {
return nil, newError(errStart, err.Error())
}
if err := node.Join(group); err != nil {
if err := node.Join(conn.group); err != nil {
node.Stop()
return nil, newError(errJoin, err.Error())
}
Expand All @@ -101,7 +101,7 @@ func newNode(conn *connection, log *logger.Logger) (*gyre.Gyre, error) {
} else {
role = "client-only"
}
log.Listen("sleuth: [%s:%d][%s %s]", group, conn.port, role, node.Name())
log.Listen("sleuth: [%s:%d][%s %s]", conn.group, conn.port, role, node.Name())
return node, nil
}

Expand Down

0 comments on commit 608a5e4

Please sign in to comment.