Skip to main content

PropagationChannel

Struct PropagationChannel 

Source
pub struct PropagationChannel {
    pub channel: Channel,
    pub gateway: String,
    pub state: ChannelState,
    pub pickup_events: Vec<String>,
    pub last_rc: Option<i32>,
    pub results: Vec<PropagationResult>,
    /* private fields */
}
Expand description

Admin-node propagation channel.

Manages the lifecycle of communication with a gateway node:

  1. Init: Send configuration (serialized topology).
  2. Config: Wait for ACK, then send control message (command).
  3. Control: Wait for ACK, then enter gather state.
  4. Gather: Collect results (stdout, stderr, retcodes, timeouts, routing).

This is a state machine that drives the Channel transport.

Fields§

§channel: Channel

The underlying communication channel.

§gateway: String

The gateway node this channel connects to.

§state: ChannelState

Current FSM state.

§pickup_events: Vec<String>

Pickup notifications produced when a CTL actually goes on the wire (upstream #594: ev_pickup fires only when the command really left the local process). Drained by the caller (TreeWorker), which forwards them as ev_pickup. write()/eof CTLs never add entries.

§last_rc: Option<i32>

Last return code from the gateway process.

§results: Vec<PropagationResult>

Collected results: (node, stream_name, data).

Implementations§

Source§

impl PropagationChannel

Source

pub fn new(gateway: &str) -> Self

Create a new propagation channel for a gateway.

Source

pub fn start(&mut self, topology_bytes: &[u8])

Start the propagation channel — send configuration.

Serializes the topology and sends it as a ConfigurationMessage.

Source

pub fn send_queued(&mut self, msg: Message)

Enqueue a control message for sending.

If the channel is already set up and the queue is empty, the message is sent immediately. Otherwise it’s queued for later.

Source

pub fn shell(&mut self, nodes: &str, command: &[u8], worker_id: u64)

Create and enqueue a shell command for execution through the channel.

Mirrors upstream PropagationChannel.shell: the target nodes are registered for pickup notification, which fires only when the CTL is actually written on the wire (#594).

Source

pub fn write(&mut self, nodes: &str, buf: &[u8], worker_id: u64)

Create and enqueue a write operation through the channel.

Source

pub fn set_write_eof(&mut self, nodes: &str, worker_id: u64)

Create and enqueue an EOF operation through the channel.

Source

pub fn recv( &mut self, msg: Message, ) -> Result<Vec<PropagationResult>, RecvError>

Process an incoming message according to the current FSM state.

Returns any propagation results generated by this message.

Source

pub fn ev_hup(&mut self, rc: i32)

Handle the gateway process closing.

Source

pub fn ev_close(&mut self)

Handle the channel closing.

Source

pub fn current_state(&self) -> ChannelState

Get the current channel state.

Source

pub fn is_gathering(&self) -> bool

Check if the channel is in gather state (ready for results).

Source

pub fn is_closed(&self) -> bool

Check if the channel is closed.

Trait Implementations§

Source§

impl Debug for PropagationChannel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.