• Stars
    star
    1,439
  • Rank 31,403 (Top 0.7 %)
  • Language
    Go
  • License
    MIT License
  • Created over 5 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ’จ A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps.

Beaver

A Real Time Messaging Server.


Beaver is a real-time messaging server. With beaver you can easily build scalable in-app notifications, realtime graphs, multiplayer games, chat applications, geotracking and more in web applications and mobile apps.

Documentation

Run Beaver on Ubuntu

Download the latest beaver binary. Make it executable from everywhere.

$ export BEAVER_LATEST_VERSION=$(curl --silent "https://api.github.com/repos/Clivern/Beaver/releases/latest" | jq '.tag_name' | sed -E 's/.*"([^"]+)".*/\1/' | tr -d v)

$ curl -sL https://github.com/Clivern/Beaver/releases/download/v{$BEAVER_LATEST_VERSION}/beaver_{$BEAVER_LATEST_VERSION}_Linux_x86_64.tar.gz | tar xz

Then install redis cluster or a single node. Update the following config file with redis configs.

Create the configs file config.yml from config.dist.yml. Something like the following:

# App configs
app:
    # Env mode (dev or prod)
    mode: ${BEAVER_APP_MODE:-prod}
    # HTTP port
    port: ${BEAVER_API_PORT:-8080}
    # Hostname
    hostname: ${BEAVER_API_HOSTNAME:-127.0.0.1}
    # TLS configs
    tls:
        status: ${BEAVER_API_TLS_STATUS:-off}
        pemPath: ${BEAVER_API_TLS_PEMPATH:-cert/server.pem}
        keyPath: ${BEAVER_API_TLS_KEYPATH:-cert/server.key}

    # API Configs
    api:
        key: ${BEAVER_API_KEY:-6c68b836-6f8e-465e-b59f-89c1db53afca}

    # Beaver Secret
    secret: ${BEAVER_SECRET:-sWUhHRcs4Aqa0MEnYwbuQln3EW8CZ0oD}

    # Runtime, Requests/Response and Beaver Metrics
    metrics:
        prometheus:
            # Route for the metrics endpoint
            endpoint: ${BEAVER_METRICS_PROM_ENDPOINT:-/metrics}

    # Application Database
    database:
        # Database driver
        driver: ${BEAVER_DB_DRIVER:-redis}

        # Redis Configs
        redis:
            # Redis address
            address: ${BEAVER_DB_REDIS_ADDR:-localhost:6379}
            # Redis password
            password: ${BEAVER_DB_REDIS_PASSWORD:- }
            # Redis database
            db: ${BEAVER_DB_REDIS_DB:-0}

    # Log configs
    log:
        # Log level, it can be debug, info, warn, error, panic, fatal
        level: ${BEAVER_LOG_LEVEL:-info}
        # Output can be stdout or abs path to log file /var/logs/beaver.log
        output: ${BEAVER_LOG_OUTPUT:-stdout}
        # Format can be json
        format: ${BEAVER_LOG_FORMAT:-json}

The run the beaver with systemd

$ beaver api -c /path/to/config.yml

API Endpoints

Create a Config app_name:

$ curl -X POST \
    -H "Content-Type: application/json" \
    -H "X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca" \
    -d '{"key":"app_name","value":"Beaver"}' \
    "http://localhost:8080/api/config"

Get a Config app_name:

$ curl -X GET \
    -H "Content-Type: application/json" \
    -H "X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca" \
    "http://localhost:8080/api/config/app_name"

{"key":"app_name","value":"Beaver"}

Update a Config app_name:

$ curl -X PUT \
    -H "Content-Type: application/json" \
    -H "X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca" \
    -d '{"value":"Beaver"}' \
    "http://localhost:8080/api/config/app_name"

Delete a Config app_name:

$ curl -X DELETE \
    -H "Content-Type: application/json" \
    -H "X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca" \
    "http://localhost:8080/api/config/app_name"

Create a Channel:

# Private Channel
$ curl -X POST \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '{"name": "app_x_chatroom_1", "type": "private"}' \
    'http://localhost:8080/api/channel'

# Public Channel
$ curl -X POST \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '{"name": "app_y_chatroom_1", "type": "public"}' \
    'http://localhost:8080/api/channel'

# Presence Channel
$ curl -X POST \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '{"name": "app_z_chatroom_5", "type": "presence"}' \
    'http://localhost:8080/api/channel'

Get a Channel:

$ curl -X GET \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '' \
    'http://localhost:8080/api/channel/app_x_chatroom_1'
{
    "created_at":1545573214,
    "listeners_count":0,
    "name":"app_x_chatroom_1",
    "subscribers_count":0,
    "type":"private",
    "updated_at":1545573214
}

$ curl -X GET \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '' \
    'http://localhost:8080/api/channel/app_y_chatroom_1'
{
    "created_at":1545573219,
    "listeners_count":0,
    "name":"app_y_chatroom_1",
    "subscribers_count":0,
    "type":"public",
    "updated_at":1545573219
}

$ curl -X GET \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '' \
    'http://localhost:8080/api/channel/app_z_chatroom_5'
{
    "created_at": 1545573225,
    "listeners": null,
    "listeners_count": 0,
    "name": "app_z_chatroom_5",
    "subscribers": null,
    "subscribers_count": 0,
    "type": "presence",
    "updated_at": 1545573225
}

Update a Channel app_y_chatroom_1:

$ curl -X PUT \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '{"type": "private"}' \
    'http://localhost:8080/api/channel/app_y_chatroom_1'

Delete a Channel app_y_chatroom_1:

$ curl -X DELETE \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '' \
    'http://localhost:8080/api/channel/app_y_chatroom_1'

Create a Client and add to app_x_chatroom_1 Channel:

$ curl -X POST \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '{"channels": ["app_x_chatroom_1"]}' \
    'http://localhost:8080/api/client'
{
    "channels": [
        "app_x_chatroom_1"
    ],
    "created_at": 1545575142,
    "id": "69775af3-5f68-4725-8162-09cab63e8427",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiNjk3NzVhZjMtNWY2OC00NzI1LTgxNjItMDljYWI2M2U4NDI3QDE1NDU1NzUxNDIiLCJ0aW1lc3RhbXAiOjE1NDU1NzUxNDJ9.EqL-nWwu5p7hJXWrKdZN3Ds2cxWVjNYmeP1mbl562nU",
    "updated_at": 1545575142
}

Get a Client 69775af3-5f68-4725-8162-09cab63e8427:

$ curl -X GET \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '' \
    'http://localhost:8080/api/client/69775af3-5f68-4725-8162-09cab63e8427'
{
    "channels": [
        "app_x_chatroom_1"
    ],
    "created_at": 1545575142,
    "id": "69775af3-5f68-4725-8162-09cab63e8427",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiNjk3NzVhZjMtNWY2OC00NzI1LTgxNjItMDljYWI2M2U4NDI3QDE1NDU1NzUxNDIiLCJ0aW1lc3RhbXAiOjE1NDU1NzUxNDJ9.EqL-nWwu5p7hJXWrKdZN3Ds2cxWVjNYmeP1mbl562nU",
    "updated_at": 1545575142
}

Subscribe a Client 69775af3-5f68-4725-8162-09cab63e8427 to a Channel app_z_chatroom_5:

$ curl -X PUT \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '{"channels": ["app_z_chatroom_5"]}' \
    'http://localhost:8080/api/client/69775af3-5f68-4725-8162-09cab63e8427/subscribe'

Unsubscribe a Client 69775af3-5f68-4725-8162-09cab63e8427 from a Channel app_z_chatroom_5:

$ curl -X PUT \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '{"channels": ["app_z_chatroom_5"]}' \
    'http://localhost:8080/api/client/69775af3-5f68-4725-8162-09cab63e8427/unsubscribe'

Delete a Client:

$ curl -X DELETE \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '' \
    'http://localhost:8080/api/client/69775af3-5f68-4725-8162-09cab63e8427'

Publish to a Channel app_x_chatroom_1:

$ curl -X POST \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '{"channel": "app_x_chatroom_1", "data": "{\"message\": \"Hello World\"}"}' \
    'http://localhost:8080/api/publish'

Broadcast to Channels ["app_x_chatroom_1"]:

$ curl -X POST \
    -H 'Content-Type: application/json' \
    -H 'X-API-Key: 6c68b836-6f8e-465e-b59f-89c1db53afca' \
    -d '{"channels": ["app_x_chatroom_1"], "data": "{\"message\": \"Hello World\"}"}' \
    'http://localhost:8080/api/broadcast'

Sample Frontend Client

function Socket(url){
    ws = new WebSocket(url);
    ws.onmessage = function(e) { console.log(e); };
    ws.onclose = function(){
        // Try to reconnect in 5 seconds
        setTimeout(function(){Socket(url)}, 5000);
    };
}

Socket("ws://localhost:8080/ws/$ID/$TOKEN");

Client:

Versioning

For transparency into our release cycle and in striving to maintain backward compatibility, Beaver is maintained under the Semantic Versioning guidelines and release process is predictable and business-friendly.

See the Releases section of our GitHub project for changelogs for each release version of Beaver. It contains summaries of the most noteworthy changes made in each release.

Bug tracker

If you have any suggestions, bug reports, or annoyances please report them to our issue tracker at https://github.com/clivern/beaver/issues

Security Issues

If you discover a security vulnerability within Beaver, please send an email to [email protected]

Contributing

We are an open source, community-driven project so please feel free to join us. see the contributing guidelines for more details.

License

ยฉ 2018, Clivern. Released under MIT License.

Beaver is authored and maintained by @Clivern.

More Repositories

1

Peanut

๐Ÿบ Deploy Databases and Services Easily for Development and Testing Pipelines.
Go
698
star
2

Walrus

๐Ÿ”ฅ Fast, Secure and Reliable System Backup, Set up in Minutes.
Go
458
star
3

Gauntlet

๐Ÿ”– Guides, Articles, Podcasts, Videos and Notes to Build Reliable Large-Scale Distributed Systems.
430
star
4

Rabbit

โšก๏ธ A lightweight service that will build and store your go projects binaries, Integrated with Github, Gitlab, Bitbucket and Bitbucket Server.
Go
197
star
5

Beetle

๐Ÿ”ฅ Kubernetes multi-cluster deployment automation service.
Go
163
star
6

Hippo

๐Ÿ’จA well crafted go packages that help you build robust, reliable, maintainable microservices.
Go
143
star
7

Poodle

๐Ÿ”ฅ A fast and beautiful command line tool to build API requests.
Go
135
star
8

Cattle

๐Ÿบ Platform to Run and Share Code. It Supports PHP, Python, Ruby, Elixir, Java, Go, Rust, C and C++.
Python
60
star
9

Buzzard

๐Ÿฆ€ Learning Rust by Examples.
Rust
57
star
10

Hamster

๐Ÿ€ A Bot toolkit for github that supports OAuth, Events, API, Custom Commands and Check Runs.
Go
41
star
11

Chunk

๐Ÿบ Asynchronous Task Queue Based on Distributed Message Passing for PHP.
PHP
36
star
12

Rhino

โ„๏ธ HTTP Mocking & Debugging Service.
Go
31
star
13

Imap

๐Ÿ“ฌ Access Mailbox Using PHP IMAP.
PHP
29
star
14

Racter

๐ŸŠ A Java Framework for Building Bots on Facebook's Messenger Platform.
Java
18
star
15

terraform-provider-boilerplate

๐Ÿ„Terraform Provider Boilerplate.
Go
17
star
16

Cluster

Golang Package for System Clustering.
Go
15
star
17

Laravel-CSV-Export

๐Ÿ”Ž Export a Large Dataset in CSV Format.
PHP
13
star
18

PyLogging

๐Ÿ‰ Python Logging Library
Python
12
star
19

file_uploader

๐Ÿ—ฟ PHP File Uploader Package
PHP
12
star
20

Chaos

๐Ÿบ A Server Chaos Maker, Set up in Minutes.
Go
11
star
21

wit-java

๐Ÿ—ฟJava Library For Wit.ai
Java
11
star
22

generator-goapi

๐Ÿ™ Yeoman Generator for Golang Microservices.
Go
6
star
23

Observability-php-sdk

๐Ÿบ Observability SDK for PHP Applications.
PHP
6
star
24

Bull

๐Ÿ“ฆMicroservices Playground with Symfony 4.
PHP
5
star
25

Apes

๐Ÿ’จChaos and Resiliency Testing Service.
Go
5
star
26

ghbot

๐Ÿค– Github Follow Bot in Python.
Python
5
star
27

Kraven

๐Ÿ’ฎ A SaaS docker management dashboard to manage your docker containers, images, volumes, networks and much more!
Python
5
star
28

Pindo

๐Ÿบ Securely Build and Run Code in Docker.
Python
5
star
29

arduino_exporter

๐Ÿบ Arduino Prometheus Exporter.
Python
4
star
30

Mammal

๐Ÿบ A Sample Microservice.
Go
3
star
31

PyArchiver

Python Compression and Archiving Library
Python
3
star
32

Glove

๐Ÿบ Prometheus Exporter Boilerplate.
Go
3
star
33

Kevin

๐Ÿบ Web Application to Inspect HTTP Requests & Build Custom Endpoints.
Python
3
star
34

Bucket

Consistent Hashing Algorithm Package for Scalable Data Distribution
Java
3
star
35

pushover-actions

๐Ÿงฌ Push notifications for github repository changes through pushover.
Go
3
star
36

Jarvis

๐Ÿ‘ปThe Hitchhiker's Guide To Go Language
Go
3
star
37

Redis-PubSub

Build Realtime Apps With Redis PubSub
HTML
2
star
38

Koala

๐Ÿงฌ Kubernetes Playground for Testing Purposes.
Go
2
star
39

Snippets

๐Ÿซ Sublime Text Snippets.
Shell
2
star
40

Toad

โ„๏ธ Containerized Application for Testing Purposes.
Go
2
star
41

MongoPlaybook

๐Ÿ“š It's worth to give it a try
2
star
42

generator-gopkg

๐Ÿ™ Yeoman Generator for Golang Packages.
JavaScript
2
star
43

Memcached

Memcached Client for PHP.
PHP
2
star
44

Monkey

๐Ÿต Apache CloudStack SDK in PHP that supports sync calls, async calls and multiple dependent calls.
PHP
2
star
45

fast-yt-videos

A WordPress Plugin That Increase Youtube Videos Loading Time
PHP
2
star
46

Walnut

๐Ÿ“ง Async Transactional Email Service.
PHP
1
star
47

Dunk

How to Create a Facebook Messenger Bot With Java
Java
1
star
48

Mantis

A Minimalist ORM for Python
Python
1
star
49

Beagle

Symfony Applications Boilerplate.
PHP
1
star
50

Thanos

๐Ÿ”ฅ53 77 69 73 73 20 4b 6e 69 66 65 21
Python
1
star
51

Events

ES tryout with Symfony 5
PHP
1
star
52

Kemet

My dotfiles.
Shell
1
star
53

PyHusky

๐Ÿบ Python Role Based Permissions Library.
Python
1
star
54

Weasel

๐Ÿบ Modern Command Line Tool for Apache Kafka.
Go
1
star
55

Oxygen

๐Ÿบ Ansible Collection to Deploy A Reliable PHP Services.
Jinja
1
star
56

Polars

A Ruby SDK for Different Linux Operating System Distributions.
Ruby
1
star
57

Fred

๐Ÿ‰ A Java Framework for Building Slack Bots.
Java
1
star
58

Trent

Experimental Chatbots With Java & Play Framework
Java
1
star
59

beaver.js

A JavaScript client for beaver, the real time messaging system.
TypeScript
1
star
60

LWT

๐Ÿบ Simple ERP Application Skeleton In Symfony 3.3.9.
PHP
1
star
61

Bear

A WordPress Themes Boilerplate.
PHP
1
star
62

Minion

Single Page Application Boilerplate.
TypeScript
1
star
63

Kevin-Cookbook

๐Ÿ™A Chef Cookbook To Deploy Kevin on Linux Servers.
Ruby
1
star
64

Frog

๐Ÿธ A Java Framework for Social Sign In.
Java
1
star
65

terraform-provider-beetle

๐Ÿ”ฅ Beetle Terraform Provider.
Go
1
star
66

Alligator

๐ŸŠ Golang Package Boilerplate.
Makefile
1
star