https://github.com/queer/sigil
sigil application gateway / controller.
https://github.com/queer/sigil
Last synced: 10 months ago
JSON representation
sigil application gateway / controller.
- Host: GitHub
- URL: https://github.com/queer/sigil
- Owner: queer
- Created: 2017-10-21T10:02:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-07T21:53:49.000Z (over 8 years ago)
- Last Synced: 2025-07-30T09:08:06.094Z (11 months ago)
- Language: Elixir
- Size: 113 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sigil
Simple distributed gateway/controller. WIP
TODO: Break dependency on etcd and use :riak_core instead.
## Configuration
The following env. vars. are expected
```
ETCD_URL=http://1.2.3.4:2379
```
## Gateway ops
The gateway supports the following operations:
```
0: HEARTBEAT
{
op: 0,
d: {
id: "1111-22-3-44444444",
bot_name: "memes",
shard: 42
}
}
1: DISPATCH
{
op: 1,
t: "EVENT_TYPE",
d: {
# whatever data goes here
}
}
2: BROADCAST_DISPATCH
{
op: 2,
d: {
# whatever data goes here
}
}
```
Note that with OP1, the `t` field is REQUIRED, and must be correctly handled by clients
`DISPATCH` gateway events are sent with a type of `protocol:event`, ex. `discord:shard`
`BROADCAST_DISPATCH` messages are meant for broadcasting to clients of a specific type; an opcode needs to be added for gateway-internal broadcasts
Additionally, the gateway expects the following channel-specific data when connecting:
```
# sigil:gateway:discord
{
id: "1234-whatever",
# Allow us to differentiate between bots and have many bots hooked up to one gateway setup
bot_name: "super-shiny-bot"
}
```
Discord shard allocation looks something like:
```
{
op: 1,
t: "discord:shard",
d: {
bot_name: "fancy bot",
id: "1-2-3-4",
shard_count: 2
}
}
```
## Commentary
### This is Elixir, why are you not using nodes like a nice human?
While it would be nice to be able to do that, I'm using websockets instead of Elixir node communication mainly just so that there's no *requirement* for parts of the stack being written in non-Elixir languages. Gateway nodes communicate with each other through `eden`, but external nodes use websockets.