gateway
Service for multiplexing many Discord websockets on top of any number of backends.
Consists of 2 components: Gateway & State Cache
NOTE: This currently only supports Tatsu's specific use case. More backends will be written in the future
as time permits.
A custom ETF parser was written from the ground up. During peak traffic, gateway uses ~4 cores for 720 shards.
State is stored in foundationdb and accessed via the State Cache (cmd/state).
Events are pushed to redis using RPUSH
. The content is the d
key of the event encoded as ETF.
Common Dependencies
- Ensure you have Go 1.13 or higher.
- Install foundationdb (both the server and clients package).
- Install redis.
Setting up the Gateway
- Add a variable in
cmd/gateway/main.go
named Token
that contains your token.
- Enable modules
export GO111MODULE=on
- Run
go build
in cmd/gateway
- To run, do
./gateway
in cmd/gateway
- To only push certain event types to the event queue, set the
WHITELIST_EVENTS
environment variable e.g WHITELIST_EVENTS=MESSAGE_CREATE,MESSAGE_REACTION_ADD
Setting up the State
- Run
go build
in cmd/state
- To run, do
./state
in cmd/state