Skip to content

Commit

Permalink
Improve components lifetime (#1204)
Browse files Browse the repository at this point in the history
  • Loading branch information
davfsa authored Sep 24, 2022
1 parent 68ee392 commit 8d520f1
Show file tree
Hide file tree
Showing 25 changed files with 2,227 additions and 1,931 deletions.
3 changes: 3 additions & 0 deletions changes/1204.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Lifetime improvements breaking changes:
- `GatewayBot.join`'s `until_close` argument removed.
- `GatewayShardImpl.get_user_id` is no longer async and will now always be available.
3 changes: 3 additions & 0 deletions changes/1204.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Lifetime improvements bugfixes:
- `GatewayShardImpl` can now be instantiated out of an async environment for consistency with other components.
- Correct signal handling in `RESTBot`.
20 changes: 20 additions & 0 deletions changes/1204.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Improve components lifetimes:
- `GatewayBot`:
- General speedups.
- Fix a lot of edge cases of hard crashes if the application shuts unexpectedly.
- More consistent signal handling.
- `run`' `shard_ids` argument can now be a `typing.Sequence`.
- Improved logging.
- `RESTBot`:
- Consistent signal handling inline with `GatewayBot`.
- Improved logging.
- Improved loop closing.
- `GatewayShardImpl`:
- New `is_connected` property to determine whether the shard is connected to the gateway.
- Faster websocket pulling and heartbeating.
- Improved error handling.
- New gateway reconnect logic to account for `resume_gateway_url`.
- Rate limiting changes:
- Chunking no longer has its own special ratelimit. Now it is shared with the rest of
"non-priority" packages sent, which is of 117/60s (3 less than the hard limit).
- "priority" packages currently only include heartbeating.
2 changes: 1 addition & 1 deletion hikari/api/event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def get_listeners(
Returns
-------
typing.Collection[typing.Callable[[T], typing.Coroutine[typing.Any, typing.Any, builtins.None]]
typing.Collection[typing.Callable[[T], typing.Coroutine[typing.Any, typing.Any, builtins.None]]]
A copy of the collection of listeners for the event. Will return
an empty collection if nothing is registered.
Expand Down
16 changes: 6 additions & 10 deletions hikari/api/shard.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,12 @@ def intents(self) -> intents_.Intents:
@property
@abc.abstractmethod
def is_alive(self) -> bool:
"""Return `builtins.True` if the shard is alive and connected.
"""Whether the shard is alive."""

Returns
-------
builtins.bool
`builtins.True` if connected, or `builtins.False` if not.
"""
@property
@abc.abstractmethod
def is_connected(self) -> bool:
"""Whether the shard is connected."""

@property
@abc.abstractmethod
Expand All @@ -127,12 +126,9 @@ def shard_count(self) -> int:
"""

@abc.abstractmethod
async def get_user_id(self) -> snowflakes.Snowflake:
def get_user_id(self) -> snowflakes.Snowflake:
"""Return the user ID.
If the shard has not connected fully yet, this should wait until the ID
is set before returning.
Returns
-------
hikari.snowflakes.Snowflake
Expand Down
Loading

0 comments on commit 8d520f1

Please sign in to comment.