aboutsummaryrefslogtreecommitdiff
path: root/src/client/bridge/gateway/mod.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2018-01-01 09:45:52 -0800
committerZeyla Hellyer <[email protected]>2018-01-01 09:45:52 -0800
commitf5a60f387d2278aa3bddac5c0a0ec110fbf5377e (patch)
treea5a73e305c50a3e33ef7e99dab6818fae3bb4a15 /src/client/bridge/gateway/mod.rs
parentDerive Hash, impl Display on ConnectionStage (diff)
downloadserenity-f5a60f387d2278aa3bddac5c0a0ec110fbf5377e.tar.xz
serenity-f5a60f387d2278aa3bddac5c0a0ec110fbf5377e.zip
Expose a method of retrieving shard status/latency
This exposes a method of retrieving a shard's status and latency through the Shard Manager, as part of the existing Shard Runner Info struct. The Shard Runner will update this whenever it notices a change.
Diffstat (limited to 'src/client/bridge/gateway/mod.rs')
-rw-r--r--src/client/bridge/gateway/mod.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/client/bridge/gateway/mod.rs b/src/client/bridge/gateway/mod.rs
index c5410e6..5c9ec69 100644
--- a/src/client/bridge/gateway/mod.rs
+++ b/src/client/bridge/gateway/mod.rs
@@ -63,6 +63,8 @@ pub use self::shard_runner_message::ShardRunnerMessage;
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::sync::mpsc::Sender;
+use std::time::Duration as StdDuration;
+use ::gateway::ConnectionStage;
/// A message either for a [`ShardManager`] or a [`ShardRunner`].
///
@@ -88,6 +90,12 @@ pub enum ShardManagerMessage {
///
/// [`ShardManagerMonitor`]: struct.ShardManagerMonitor.html
Restart(ShardId),
+ /// An update from a shard runner,
+ ShardUpdate {
+ id: ShardId,
+ latency: Option<StdDuration>,
+ stage: ConnectionStage,
+ },
/// Indicator that a [`ShardManagerMonitor`] should fully shutdown a shard
/// without bringing it back up.
///
@@ -140,7 +148,12 @@ impl Display for ShardId {
/// [`ShardRunner`]: struct.ShardRunner.html
#[derive(Debug)]
pub struct ShardRunnerInfo {
+ /// The latency between when a heartbeat was sent and when the
+ /// acknowledgement was received.
+ pub latency: Option<StdDuration>,
/// The channel used to communicate with the shard runner, telling it
/// what to do with regards to its status.
pub runner_tx: Sender<ShardClientMessage>,
+ /// The current connection stage of the shard.
+ pub stage: ConnectionStage,
}