crystalcent
Crystalcent
crystalcent is a Centrifugo API wrapper writes with Crystal Language.
Inspired from gitlab.
Installation
- Add the dependency to your
shard.yml
:
dependencies:
cent:
github: devops-israel/crystalcent
- Run
shards install
Usage
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
Implemented API
Completed
API
POST /api
- Main API endpoint for all actions
Supported API calls:
- publish
- broadcast
- unsubscribe
- disconnect
- presence
- presence_stats
- history
- channels
- info
Server Health
GET /health
- returns 200 OK (you need to configure Centrifugo to allow (health endpoint)[https://centrifugal.github.io/centrifugo/server/configuration/#healthcheck-endpoint])
Development
Prerequisites
Commands
- 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.
Contributing
- 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
Contributors
- Josh Dvir - creator and maintainer
License
MIT License © devops-israel
Repository
crystalcent
Owner
Statistic
- 3
- 1
- 0
- 0
- 2
- over 5 years ago
- June 6, 2019
License
MIT License
Links
Synced at
Sun, 24 Nov 2024 00:28:09 GMT
Languages