Giter Site home page Giter Site logo

centcom's People

Contributors

synw avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

centcom's Issues

Some API design questions

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.