Skip to content

Commit

Permalink
refactor(gateway): rework queue, remove Queue trait
Browse files Browse the repository at this point in the history
  • Loading branch information
vilgotf committed Jun 25, 2023
1 parent 3501ab4 commit dc7962d
Show file tree
Hide file tree
Showing 19 changed files with 227 additions and 794 deletions.
5 changes: 0 additions & 5 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ labels:
matcher:
files: "twilight-gateway/**/*"

- label: "c-gateway-queue"
sync: true
matcher:
files: "twilight-gateway-queue/**/*"

- label: "c-http"
sync: true
matcher:
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ members = [
"twilight",
"twilight-cache-inmemory",
"twilight-gateway",
"twilight-gateway-queue",
"twilight-http",
"twilight-http-ratelimiting",
"twilight-lavalink",
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ easier;
- A calculator to calculate the permissions of a member in a guild or
channel.

### [`twilight-gateway-queue`]

A trait and some implementations that are used by the gateway to ratelimit
identify calls. Developers should prefer to use the re-exports of these
crates through the gateway.

## Examples

The following example is a template for bootstrapping a new bot using
Expand Down Expand Up @@ -212,7 +206,6 @@ All first-party crates are licensed under [ISC][LICENSE.md]
[logo]: https://raw.githubusercontent.com/twilight-rs/twilight/main/logo.png
[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust
[`twilight-cache-inmemory`]: https://twilight.rs/chapter_1_crates/section_4_cache_inmemory.html
[`twilight-gateway-queue`]: https://twilight.rs/chapter_1_crates/section_7_first_party/section_5_gateway_queue.html
[`twilight-gateway`]: https://twilight.rs/chapter_1_crates/section_3_gateway.html
[`twilight-http`]: https://twilight.rs/chapter_1_crates/section_2_http.html
[`twilight-lavalink`]: https://twilight.rs/chapter_1_crates/section_7_first_party/section_3_lavalink.html
Expand Down
1 change: 0 additions & 1 deletion book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
- [Mention](./chapter_1_crates/section_7_first_party/section_2_mention.md)
- [Lavalink](./chapter_1_crates/section_7_first_party/section_3_lavalink.md)
- [Util](./chapter_1_crates/section_7_first_party/section_4_util.md)
- [Gateway Queue](./chapter_1_crates/section_7_first_party/section_5_gateway_queue.md)
- [Third-party](./chapter_1_crates/section_8_third_party.md)
- [Multi-Serviced Approach](./chapter_2_multi-serviced_approach.md)
- [Bots Using Twilight](./chapter_3_bots_using_twilight.md)
Expand Down

This file was deleted.

21 changes: 4 additions & 17 deletions book/src/chapter_2_multi-serviced_approach.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,13 @@ you have a small bot and just want to get it going in a monolithic application,
then it's also a good choice. It's easy to split off parts of your application
into other services as your application grows.

## Gateway groups
## Gateway

One of the popular design choices when creating a multi-serviced application is
to have a service that only connects shards to the gateway and sends the events
to a broker to be processed. As bots grow into hundreds or thousands of shards,
multiple instances of the application can be created and groups of shards can be
managed by each. Twilight is an excellent choice for this use case: you can
receive either events that come in in a loop and send the payloads to the
appropriate broker stream, or you can loop over received payloads' bytes to send
off.

## Gateway session ratelimiting

If multiple shard groups are used, then they need to be queued and their session
initialization ratelimited. The Gateway includes a Queue trait which can be
implemented; the gateway will submit a request to the queue before starting a
session. Twilight comes with a queue that supports sharding and Large Bot
sharding, but when multiple shard groups are in use then a custom queue will
need to be implemented. Refer to [gateway-queue] for an example of this.
to a broker to be processed. Twilight is an excellent choice for this use case:
just receive and send the payloads to the appropriate broker stream. Twilight
shards need only partially deserialize payloads to function.

## HTTP proxy ratelimiting

Expand All @@ -42,5 +30,4 @@ it's flexible enough to do anything you need, and if you find something it can't
then we'll fix it. The goal is to remove all limitations on designs and allow
you to do what you need.

[gateway-queue]: https://github.com/twilight-rs/gateway-queue
[http-proxy]: https://github.com/twilight-rs/http-proxy
227 changes: 0 additions & 227 deletions twilight-gateway-queue/CHANGELOG.md

This file was deleted.

30 changes: 0 additions & 30 deletions twilight-gateway-queue/Cargo.toml

This file was deleted.

Loading

0 comments on commit dc7962d

Please sign in to comment.