pub struct SessionHandle { /* private fields */ }Expand description
Unified handle for controlling remote sessions. Handle for controlling a remote session.
Created by attaching to a remote session. Provides methods to:
- Query and observe session state
- Issue control commands (trigger staging, release blocks)
- Transfer control bidirectionally (yield/acquire)
- Pull blocks via RDMA
§Usage
// Attach to remote session
let mut handle = leader.attach_session(remote_id, session_id).await?;
// Wait for initial state
let state = handle.wait_for_ready().await?;
// Trigger staging if needed
if state.g3_pending > 0 {
handle.trigger_staging().await?;
handle.wait_for_ready().await?;
}
// Pull blocks via RDMA
let notification = handle.pull_blocks_rdma(&state.g2_blocks, &local_block_ids).await?;
notification.await?;
// Notify remote and detach
handle.mark_blocks_pulled(hashes).await?;
handle.detach().await?;Implementations§
Source§impl SessionHandle
impl SessionHandle
Sourcepub fn with_rdma_support(
self,
parallel_worker: Arc<dyn ParallelWorkers>,
) -> Self
pub fn with_rdma_support( self, parallel_worker: Arc<dyn ParallelWorkers>, ) -> Self
Add RDMA support to this handle.
Sourcepub fn session_id(&self) -> SessionId
pub fn session_id(&self) -> SessionId
Get the session ID.
Sourcepub fn remote_instance(&self) -> InstanceId
pub fn remote_instance(&self) -> InstanceId
Get the remote instance ID.
Sourcepub fn local_instance(&self) -> InstanceId
pub fn local_instance(&self) -> InstanceId
Get the local instance ID.
Sourcepub fn current_state(&self) -> SessionStateSnapshot
pub fn current_state(&self) -> SessionStateSnapshot
Get the current state snapshot (non-blocking).
Sourcepub fn phase(&self) -> SessionPhase
pub fn phase(&self) -> SessionPhase
Get the current phase.
Sourcepub fn remote_control_role(&self) -> ControlRole
pub fn remote_control_role(&self) -> ControlRole
Get the current control role of the remote session.
Sourcepub fn has_changed(&self) -> bool
pub fn has_changed(&self) -> bool
Check if state has changed since last read.
Sourcepub async fn wait_for_change(&mut self) -> Result<SessionStateSnapshot>
pub async fn wait_for_change(&mut self) -> Result<SessionStateSnapshot>
Wait for state to change.
Sourcepub async fn wait_for_ready(&mut self) -> Result<SessionStateSnapshot>
pub async fn wait_for_ready(&mut self) -> Result<SessionStateSnapshot>
Wait for the session to reach Ready phase (all blocks in G2).
Sourcepub async fn wait_for_complete(&mut self) -> Result<SessionStateSnapshot>
pub async fn wait_for_complete(&mut self) -> Result<SessionStateSnapshot>
Wait for the session to complete.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if the session is complete.
Sourcepub fn get_g2_blocks(&self) -> Vec<BlockInfo>
pub fn get_g2_blocks(&self) -> Vec<BlockInfo>
Get G2 blocks from current state.
Sourcepub fn g3_pending_count(&self) -> usize
pub fn g3_pending_count(&self) -> usize
Get count of G3 blocks pending staging.
Sourcepub fn ready_layer_range(&self) -> Option<Range<usize>>
pub fn ready_layer_range(&self) -> Option<Range<usize>>
Get the layer range that is ready for transfer.
Returns None if all layers are ready or layerwise tracking is not active.
Returns Some(range) if only specific layers are ready.
Sourcepub async fn trigger_staging(&self) -> Result<()>
pub async fn trigger_staging(&self) -> Result<()>
Trigger G3→G2 staging on the remote session.
Idempotent - no-op if already staging or staged.
Sourcepub async fn mark_blocks_pulled(
&self,
pulled_hashes: Vec<SequenceHash>,
) -> Result<()>
pub async fn mark_blocks_pulled( &self, pulled_hashes: Vec<SequenceHash>, ) -> Result<()>
Notify remote that blocks have been pulled.
Call after successfully pulling blocks via RDMA.
Sourcepub async fn detach(self) -> Result<()>
pub async fn detach(self) -> Result<()>
Detach from the session.
Consumes the handle. The remote session will release remaining blocks.
Sourcepub async fn yield_control(&self) -> Result<()>
pub async fn yield_control(&self) -> Result<()>
Yield control to the remote peer.
After yielding, this handle transitions to Neutral and the remote can acquire control if desired.
Sourcepub async fn acquire_control(&self) -> Result<()>
pub async fn acquire_control(&self) -> Result<()>
Attempt to acquire control from the remote peer.
Valid when remote is in Neutral state.
Sourcepub fn has_remote_metadata(&self) -> bool
pub fn has_remote_metadata(&self) -> bool
Check if remote metadata has been imported.
Sourcepub async fn ensure_metadata_imported(&mut self) -> Result<()>
pub async fn ensure_metadata_imported(&mut self) -> Result<()>
Ensure remote metadata is imported (lazy loading).
Sourcepub async fn pull_blocks_rdma(
&mut self,
blocks: &[BlockInfo],
local_dst_block_ids: &[BlockId],
) -> Result<TransferCompleteNotification>
pub async fn pull_blocks_rdma( &mut self, blocks: &[BlockInfo], local_dst_block_ids: &[BlockId], ) -> Result<TransferCompleteNotification>
Pull blocks from remote G2 to local G2 via RDMA.
This method:
- Ensures remote metadata is imported
- Executes SPMD-aware transfer (worker N pulls from remote worker N)
- Returns notification that completes when all transfers done
Sourcepub fn pull_blocks_rdma_explicit(
&self,
blocks: &[BlockInfo],
local_dst_block_ids: &[BlockId],
) -> Result<TransferCompleteNotification>
pub fn pull_blocks_rdma_explicit( &self, blocks: &[BlockInfo], local_dst_block_ids: &[BlockId], ) -> Result<TransferCompleteNotification>
Pull blocks with explicit metadata pre-import.
Caller must have already ensured metadata is imported.
Sourcepub async fn pull_blocks_rdma_with_options(
&mut self,
blocks: &[BlockInfo],
local_dst_block_ids: &[BlockId],
options: TransferOptions,
) -> Result<TransferCompleteNotification>
pub async fn pull_blocks_rdma_with_options( &mut self, blocks: &[BlockInfo], local_dst_block_ids: &[BlockId], options: TransferOptions, ) -> Result<TransferCompleteNotification>
Pull blocks from remote G2 to local G2 via RDMA with transfer options.
This method allows specifying transfer options like layer range for layerwise transfer. Use this when you only want to pull specific layers.
§Example
// Pull only layer 0
let notification = handle.pull_blocks_rdma_with_options(
&state.g2_blocks,
&local_block_ids,
TransferOptions::builder().layer_range(0..1).build(),
).await?;
notification.await?;Sourcepub fn pull_blocks_rdma_with_options_explicit(
&self,
blocks: &[BlockInfo],
local_dst_block_ids: &[BlockId],
options: TransferOptions,
) -> Result<TransferCompleteNotification>
pub fn pull_blocks_rdma_with_options_explicit( &self, blocks: &[BlockInfo], local_dst_block_ids: &[BlockId], options: TransferOptions, ) -> Result<TransferCompleteNotification>
Pull blocks with options and explicit metadata pre-import.
Caller must have already ensured metadata is imported.
Auto Trait Implementations§
impl !RefUnwindSafe for SessionHandle
impl !UnwindSafe for SessionHandle
impl Freeze for SessionHandle
impl Send for SessionHandle
impl Sync for SessionHandle
impl Unpin for SessionHandle
impl UnsafeUnpin for SessionHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);