Skip to content

multi-process template #4

@vilgotf

Description

@vilgotf

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:

  1. Cleanly: another worker called GET /events --> shutdown
  2. Uncleanly: gateway exited --> reconnect

Events in the InteractionCreate stream should be retained for 3 seconds in case another worker connects in time.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions