shibe

🧙
Sharding backend infrastructure for Nino v2, handles as a sharding operator for Nino.

Why?

I feel like this was needed because I wanted to keep Discord’s gateway multi-threaded without blocking the Node.js thread, and this is the possible way I can do it. I will keep Nino in TypeScript, but I wanted to have an operator handling shards and add/remove shards without having to reload the bot and having it available without any restarts.

It’s possible using singyeong for sending messages between production and staging instances about Discord events, health-related issues, etc. and singyeong is pretty cool as in features, and I wanted to use it as a messaging router. The database is handled under the bot and cached through Redis, so we don’t have overlying connections between database connections and possibly destroying data if I am dumb.

I would like to note that shibe is for Nino’s use-case and probably does not fit under your needs, this is just a project on how the backend infrastructure for Nino will work. Self-hosted instances will not require shibe and can be handled with Eris (the old gateway library we use) without any pressure. This is mainly for production and staging.

Isn’t this just another “discord clustering” thing?

I wouldn’t really say so, and here me out:

shibe doesn’t rely on the clustering idea, which might sound weird. I won’t add automatic scaling since Nino uses Kubernetes to manage scaling, so that’s not an issue there. It’s just a backend job to scale shards in a multi-threaded environment and dispatch events faster + reliably.

It also doesn’t rely on IPC, or a relay service! It’s just a WebSocket connection like Discord’s gateway! I wanted to create an environment that feels similar to Discord’s gateway. You can see the implementation details, but I added some packets of my own to help manage shibe, nothing more!

Modules

  • core ~ Core infrastructure for shibe, most of the heavy work is here.
  • gateway ~ Gateway connection towards Discord.
  • singyeong ~ Library for interacting with singyeong using Ktor.

License

shibe is released under the GPL-3.0 License, read the LICENSE file for more information.

GitHub