Gateway: Add connection timeout, add Config to gateway. (#51)

This change fixes tasks hanging due to rare cases of messages being lost between full Discord reconnections by placing a configurable timeout on the `ConnectionInfo` responses. This is a companion fix to [serenity#1255](https://github.com/serenity-rs/serenity/pull/1255). To make this doable, `Config`s are now used by all versions of `Songbird`/`Call`, and relevant functions are  added to simplify setup with configuration. These are now non-exhaustive, correcting an earlier oversight. For future extensibility, this PR moves the return type of `join`/`join_gateway` into a custom future (no longer leaking flume's `RecvFut` type).

Additionally, this fixes the Makefile's feature sets for driver/gateway-only compilation.

This is a breaking change in:
* the return types of `join`/`join_gateway`
* moving `crate::driver::Config` -> `crate::Config`,
* `Config` and `JoinError` becoming `#[non_breaking]`.

This was tested via `cargo make ready`, and by testing `examples/serenity/voice_receive` with various timeout settings.
This commit is contained in:
Kyle Simpson
2021-03-29 19:51:13 +01:00
parent f449d4f679
commit 1fc3dc2259
18 changed files with 426 additions and 119 deletions

View File

@@ -37,6 +37,7 @@
//! [`ConnectionInfo`]: struct@ConnectionInfo
//! [lavalink]: https://github.com/Frederikam/Lavalink
mod config;
pub mod constants;
#[cfg(feature = "driver-core")]
pub mod driver;
@@ -50,6 +51,8 @@ pub(crate) mod info;
#[cfg(feature = "driver-core")]
pub mod input;
#[cfg(feature = "gateway-core")]
pub mod join;
#[cfg(feature = "gateway-core")]
mod manager;
#[cfg(feature = "serenity")]
pub mod serenity;
@@ -61,6 +64,7 @@ pub mod tracks;
mod ws;
#[cfg(feature = "driver-core")]
/// Opus encoder bitrate settings.
pub use audiopus::{self as opus, Bitrate};
#[cfg(feature = "driver-core")]
pub use discortp as packet;
@@ -86,4 +90,5 @@ pub use crate::{handler::*, manager::*};
#[cfg(feature = "serenity")]
pub use crate::serenity::*;
pub use config::Config;
pub use info::ConnectionInfo;