[][src]Struct serenity::client::bridge::gateway::ShardQueuer

pub struct ShardQueuer<H: EventHandler + Send + Sync + 'static> {
    pub data: Arc<Mutex<ShareMap>>,
    pub event_handler: Arc<H>,
    pub framework: Arc<Mutex<Option<Box<dyn Framework + Send>>>>,
    pub last_start: Option<Instant>,
    pub manager_tx: Sender<ShardManagerMessage>,
    pub queue: VecDeque<(u64, u64)>,
    pub runners: Arc<Mutex<HashMap<ShardId, ShardRunnerInfo>>>,
    pub rx: Receiver<ShardQueuerMessage>,
    pub threadpool: ThreadPool,
    pub token: Arc<Mutex<String>>,
    pub voice_manager: Arc<Mutex<ClientVoiceManager>>,
    pub ws_url: Arc<Mutex<String>>,
}

The shard queuer is a simple loop that runs indefinitely to manage the startup of shards.

A shard queuer instance should be run in its own thread, due to the blocking nature of the loop itself as well as a 5 second thread sleep between shard starts.

Fields

A copy of Client::data to be given to runners for contextual dispatching.

A reference to an EventHandler, such as the one given to the Client.

A copy of the framework

The instant that a shard was last started.

This is used to determine how long to wait between shard IDENTIFYs.

A copy of the sender channel to communicate with the ShardManagerMonitor.

The shards that are queued for booting.

This will typically be filled with previously failed boots.

A copy of the map of shard runners.

A receiver channel for the shard queuer to be told to start shards.

A copy of a threadpool to give shard runners.

For example, when using the Client, this will be a copy of Client::threadpool.

A copy of the token to connect with.

A copy of the client's voice manager.

A copy of the URI to use to connect to the gateway.

Methods

impl<H: EventHandler + Send + Sync + 'static> ShardQueuer<H>
[src]

Begins the shard queuer loop.

This will loop over the internal rx for ShardQueuerMessages, blocking for messages on what to do.

If a ShardQueuerMessage::Start is received, this will:

  1. Check how much time has passed since the last shard was started
  2. If the amount of time is less than the ratelimit, it will sleep until that time has passed
  3. Start the shard by ID

If a ShardQueuerMessage::Shutdown is received, this will return and the loop will be over.

Note: This should be run in its own thread due to the blocking nature of the loop.

Auto Trait Implementations

impl<H> Send for ShardQueuer<H>

impl<H> !Sync for ShardQueuer<H>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> Erased for T

impl<T> Typeable for T where
    T: Any

Get the TypeId of this object.

impl<T> UnsafeAny for T where
    T: Any