Skip to content

refactor(gateway)!: rewrite Inflater#1993

Merged
7596ff merged 17 commits intonextfrom
vilgotf/refactor/gateway/inflater-rewrite
Dec 29, 2022
Merged

refactor(gateway)!: rewrite Inflater#1993
7596ff merged 17 commits intonextfrom
vilgotf/refactor/gateway/inflater-rewrite

Conversation

@vilgotf
Copy link
Member

@vilgotf vilgotf commented Nov 12, 2022

Removes the Inflater internal buffer and instead returns the decompressed (and now String) message directly. Note that this does not add any allocations since the old implementation took the buffer on each message (which also probably caused bugs when events were split across two compressed messages). The old implementation also faultily always returned None when decompression was disabled, making it impossible to process messages. There are also other smaller improvements caused by this rewrite.

Removes the Message::Binary variant since decompressed must now be Strings to be valid. Users should not have a problem being restricted to UTF-8 messages since the gateway only accepts JSON encoded events.

Removes the metrics feature and conditionally exposes the Inflater directly for users to use however they wish.

Fixes #1990

@vilgotf vilgotf added c-gateway Affects the gateway crate t-feature Addition of a new feature t-fix Fixes a bug in the library t-refactor Refactors APIs or code. labels Nov 12, 2022
@vilgotf vilgotf requested a review from Erk- November 12, 2022 14:33
@github-actions github-actions bot added the m-breaking change Breaks the public API. label Nov 12, 2022
@vilgotf vilgotf force-pushed the vilgotf/refactor/gateway/inflater-rewrite branch 3 times, most recently from 1b44d51 to 341be71 Compare November 13, 2022 20:05
@vilgotf vilgotf force-pushed the vilgotf/refactor/gateway/inflater-rewrite branch from 341be71 to 97edc23 Compare November 14, 2022 19:55
@vilgotf vilgotf changed the base branch from old-next to next November 14, 2022 19:55
@vilgotf vilgotf added the t-perf Improves performace label Nov 18, 2022
Copy link
Member

@Erk- Erk- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes looks overall good

I am not really a fan of switching it to parse strings around for a couple of reasons

  • It is less flexible in general for what you can do with them
  • It makes some optimizations have less gain such as simd-json which does with simd accelerated checking of utf-8.

@7596ff 7596ff merged commit 1c55940 into next Dec 29, 2022
@7596ff 7596ff deleted the vilgotf/refactor/gateway/inflater-rewrite branch December 29, 2022 02:16
spring4175 pushed a commit that referenced this pull request Feb 4, 2023
The book's TLS docs for `twilight-lavalink` incorrectly mentions
`async-tungstenite` as the WebSocket library instead of
`tokio-tungstenite`. This PR, like #1982 for the gateway, corrects this.

Additionally removes the mention of the gateway's `metric` feature,
which was removed in PR #1993.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c-gateway Affects the gateway crate m-breaking change Breaks the public API. t-feature Addition of a new feature t-fix Fixes a bug in the library t-perf Improves performace t-refactor Refactors APIs or code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[next] Hello and Ready payloads can not be deserialized with the "simd-json" feature active

4 participants