crystalcent is a Centrifugo API wrapper writes with Crystal Language.
Inspired from gitlab.
- Add the dependency to your
shard.yml
:
dependencies:
cent:
github: devops-israel/crystalcent
- Run
shards install
require "cent"
# configuration
endpoint = "https://cent.example.com" # No tailing forward slash
api_key = "<api_key>"
# initialize a new client with user and password for basic auth
centrifugo_client = Cent.client(endpoint, api_key)
# => #<Cent::Client:0x101653f20 @endpoint="https://cent.example.com", @api_key="xxx">
# server health
centrifugo_client.available?
# true
centrifugo_client.publish("channel_x", {text: "value1"})
centrifugo_client.broadcast(["channel_x", "channel_y"], {"stam" => "data"})
centrifugo_client.unsubscribe("channel_x", "user_x")
centrifugo_client.disconnect("user_x")
centrifugo_client.presence("channel_x")
centrifugo_client.presence_stats("channel_x")
centrifugo_client.history("channel_x")
centrifugo_client.channels
centrifugo_client.info
POST /api
- Main API endpoint for all actions
- publish
- broadcast
- unsubscribe
- disconnect
- presence
- presence_stats
- history
- channels
- info
GET /health
- returns 200 OK (you need to configure Centrifugo to allow (health endpoint)[https://centrifugal.github.io/centrifugo/server/configuration/#healthcheck-endpoint])
- From inside the root of the project run
docker-compose up
- The container is configured to run tests every time a file is changed so just start developing.
- Fork it (https://github.com/devops-israel/crystalcent/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Josh Dvir - creator and maintainer
MIT License © devops-israel