Library: Add compatibility for legacy Tokio 0.2 (#40)
Adds support to the library for tokio 0.2 backward-compatibility. This should hopefully benefit, and prevent lavalink-rs from being blocked on this feature. These can be reached using, e.g., `gateway-tokio-02`, `driver-tokio-02`, `serenity-rustls-tokio-02`, and `serenity-native-tokio-02` features. Naturally, this requires some jiggering about with features and the underlying CI, which has been taken care of. Twilight can't be handled in this way, as their last tokio 0.2 version uses the deprecated Discord Gateway v6.
This commit is contained in:
@@ -16,11 +16,14 @@ use super::{
|
||||
use crate::events::CoreContext;
|
||||
use flume::{Receiver, RecvError, Sender};
|
||||
use message::*;
|
||||
use tokio::runtime::Handle;
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
use tokio::{runtime::Handle, spawn};
|
||||
#[cfg(feature = "tokio-02-marker")]
|
||||
use tokio_compat::{runtime::Handle, spawn};
|
||||
use tracing::{error, info, instrument};
|
||||
|
||||
pub(crate) fn start(config: Config, rx: Receiver<CoreMessage>, tx: Sender<CoreMessage>) {
|
||||
tokio::spawn(async move {
|
||||
spawn(async move {
|
||||
info!("Driver started.");
|
||||
runner(config, rx, tx).await;
|
||||
info!("Driver finished.");
|
||||
@@ -38,7 +41,7 @@ fn start_internals(core: Sender<CoreMessage>, config: Config) -> Interconnect {
|
||||
};
|
||||
|
||||
let ic = interconnect.clone();
|
||||
tokio::spawn(async move {
|
||||
spawn(async move {
|
||||
info!("Event processor started.");
|
||||
events::runner(ic, evt_rx).await;
|
||||
info!("Event processor finished.");
|
||||
|
||||
Reference in New Issue
Block a user