ursiform / sleuth Goto Github PK
View Code? Open in Web Editor NEWA Go library for master-less peer-to-peer autodiscovery and RPC between HTTP services
Home Page: http://ursiform.github.io/sleuth/
License: MIT License
A Go library for master-less peer-to-peer autodiscovery and RPC between HTTP services
Home Page: http://ursiform.github.io/sleuth/
License: MIT License
Hi !
I have this code running on multiple computers on the same network
package main
import (
"bytes"
"fmt"
"github.com/gorilla/mux"
"github.com/ursiform/sleuth"
"net/http"
"time"
)
var (
client *sleuth.Client
)
func handler(res http.ResponseWriter, req *http.Request) {
fmt.Println("test :D")
}
func main() {
router := mux.NewRouter()
router.HandleFunc("/", handler).Methods("POST")
client, _ = sleuth.New(&sleuth.Config{Service: "comment-service", Handler: router})
go surveilCurrentAvailableServices()
fmt.Println("ready...")
http.ListenAndServe(":9872", router)
}
func surveilCurrentAvailableServices() {
for {
fmt.Println(client)
client.WaitFor("comment-service")
//try to make a post to the another services
input := "This is the value I am inputting."
body := bytes.NewBuffer([]byte(input))
request, _ := http.NewRequest("POST", "sleuth://comment-service/", body)
client.Do(request)
time.Sleep(500 * time.Millisecond)
}
}
I run the code first on C1 (computer 1) then C2 and then C3
With the fmt.Println(client)
I get this client object:
On C1:
&{500ms 0xc8201046e0 false SLEUTH-v1 145 0xc8200145a0 0xc820102470 0xc8200e2128 0xc820014640 map[B18125:comment-service F5C8BB:comment-service] 0xc820102480}
On C2
&{500ms 0x107ce3d0 false SLEUTH-v1 0 0x10712540 0x107cc120 0x107be7bc 0x10712630 map[B18125:comment-service] 0x107cc128}
On C3:
&{500ms 0x107ce3d0 false SLEUTH-v1 0 0x10712540 0x107cc120 0x107be7cc 0x10712630 map[] 0x107cc128}
So C1 detect C2 and C3 but C3 doesn't find the service of C1.
So when you run the code sleuth doesn't find services which are already running on another devices on the network.
Is that an issue or is there a solution for that?
Moreover the POST request made on sleuth://comment-service/
doesn't work and I doesn't understand why.
Thanks in advance!
Best regards
I am having an issue with service discovery using Sleuth. I have followed your example without any changes except specifying the interface on the config. I've also made sure all UDP/TCP ports are open but still my client is not able to discover the service, it just keeps hanging on WaitFor(). If I run the service and client on same machine it works obviously but not when I run them on different machines on the same network.
I have been using Sleuth with latest Gyre version (go get ) and libzmq 4.2.1/4.2.3.
Is there any specific version of Gyre and libzmq that Sleuth requires as it seems Sleuth hasn't been updated for quite some time.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.