synw / centcom Goto Github PK
View Code? Open in Web Editor NEWA Go API for Centrifugo
A Go API for Centrifugo
Hi, just looking through readme examples for now:
cli := centcom.New("locahost", 8001, "secret_key")
cli, err := centcom.Connect(cli)
if err != nil {
fmt.Println(err)
return
}
defer centcom.Disconnect(cli)
Maybe a more natural way would be:
cli := centcom.New("locahost", 8001, "secret_key")
err := cli.Connect()
if err != nil {
fmt.Println(err)
return
}
defer cli.Disconnect()
The same for Subscribe
method - it also returns cli
as first return value. I can miss sth though.
Then:
// listen
go func() {
fmt.Println("Listening ...")
for msg := range(cli.Channels) {
if msg.Channel == "public:data" {
fmt.Println("PAYLOAD", msg.Payload, msg.UID)
}
}
}()
Interesting approach. Just wondering without investigating code yet - will this routine work after reconnect to Centrifugo? Actually reconnecting part is the most difficult in all Centrifugo clients - I always struggle with it.
But the most important question I came to: in our clients we distinguish between HTTP API and client libraries (gocent
for backend, centrifuge-go
for client facing side) - and one of the reasons for it is different security politics: HTTP client can know secret
key because it works from app backend, while client library must ask backend for connection credentials (without knowing secret
key). Now this wrapper uses the same constructor for everything accepting secret
key as initialization argument. This means that this wrapper can only be used from app backend (if use Centrifugo idiomatically) so application client does not have access to secret
key.
Noticed a typo in Subscribe
method - it's now called Suscribe. The same for Unsubscribe
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.