Twilight's architecture supports partitioning a bot into multiple processes, but it can be difficult to know how to. We should provide a template for the most common partition: a stateful gateway (server) and a stateless worker (client). To update commands, the worker retains support for the previous commands (it may optionally be restarted without such support once the command update has propagated). IPC is easiest done through HTTP; below is a sample gateway API:
GET /events/{type}: gateway forwards incoming events
GET /{type}/{id}: gateway retrieves a cached resource
POST /shards/{id}: gateway submits a message
The events stream terminates in one of two ways:
- Cleanly: another worker called
GET /events --> shutdown
- Uncleanly: gateway exited --> reconnect
Events in the InteractionCreate stream should be retained for 3 seconds in case another worker connects in time.
Twilight's architecture supports partitioning a bot into multiple processes, but it can be difficult to know how to. We should provide a template for the most common partition: a stateful gateway (server) and a stateless worker (client). To update commands, the worker retains support for the previous commands (it may optionally be restarted without such support once the command update has propagated). IPC is easiest done through HTTP; below is a sample gateway API:
GET /events/{type}: gateway forwards incoming eventsGET /{type}/{id}: gateway retrieves a cached resourcePOST /shards/{id}: gateway submits a messageThe events stream terminates in one of two ways:
GET /events--> shutdownEvents in the
InteractionCreatestream should be retained for 3 seconds in case another worker connects in time.