Struct Worker

Source
pub struct Worker {
    grpc_client: ControllerClient<Channel>,
    hostname: String,
    is_active: Arc<Mutex<bool>>,
    current_m_id: Arc<Mutex<u32>>,
    outbound_tx: Option<Sender<Data>>,
    abort_s: Arc<AtomicBool>,
}
Expand description

The worker that is run at the anycast sites and performs measurements as instructed by the orchestrator.

The worker is responsible for establishing a connection with the orchestrator, receiving tasks, and performing measurements.

§Fields

  • ‘grpc_client’ - the worker gRPC connection with the orchestrator
  • ‘hostname’ - the hostname of the worker
  • ‘is_active’ - boolean value that is set to true when the worker is currently doing a measurement
  • ‘current_m_id’ - contains the ID of the current measurement
  • ‘outbound_tx’ - contains the sender of a channel to the outbound prober that tasks are send to
  • ‘inbound_f’ - an atomic boolean that is used to signal the inbound thread to stop listening for packets

Fields§

§grpc_client: ControllerClient<Channel>§hostname: String§is_active: Arc<Mutex<bool>>§current_m_id: Arc<Mutex<u32>>§outbound_tx: Option<Sender<Data>>§abort_s: Arc<AtomicBool>

Implementations§

Source§

impl Worker

Source

pub async fn new(args: &ArgMatches) -> Result<Worker, Box<dyn Error>>

Create a worker instance, which includes establishing a connection with the orchestrator.

Extracts the parameters of the command-line arguments.

§Arguments
  • ‘args’ - contains the parsed command-line arguments
Source

async fn connect( address: String, fqdn: Option<&String>, ) -> Result<ControllerClient<Channel>, Box<dyn Error>>

Connect to the orchestrator.

§Arguments
  • ‘address’ - the address of the orchestrator in string format, containing both the IPv4 address and port number

  • ‘fqdn’ - an optional string that contains the FQDN of the orchestrator certificate (if TLS is enabled)

§Example
let client = connect("127.0.0.0:50001", true);
Source

fn init(&mut self, task: Task, worker_id: u16, abort_s: Option<Arc<AtomicBool>>)

Initialize a new measurement by creating outbound and inbound threads, and ensures task results are sent back to the orchestrator.

Extracts the protocol type from the measurement definition, and determines which source address to use. Creates a socket to send out probes and receive replies with, calls the appropriate inbound & outbound functions. Creates an additional thread that forwards task results to the orchestrator.

§Arguments
  • ‘task’ - the first ‘Task’ message sent by the orchestrator, that contains the measurement definition

  • ‘worker_id’ - the unique ID of this worker

  • ‘abort_s’ - an optional Arc that is used to signal the outbound thread to stop sending probes

Source

async fn connect_to_server(&mut self) -> Result<(), Box<dyn Error>>

Establish a formal connection with the orchestrator.

Obtains a unique worker ID from the orchestrator, establishes a stream for receiving tasks, and handles tasks as they come in.

Source

async fn send_result_to_server( &mut self, task_result: TaskResult, ) -> Result<(), Box<dyn Error>>

Send a TaskResult to the orchestrator

Source

async fn measurement_finish_to_server( &mut self, finished: Finished, ) -> Result<(), Box<dyn Error>>

Let the orchestrator know the current measurement is finished.

When a measurement is finished the orchestrator knows not to expect any more results from this worker.

§Arguments
  • ‘finished’ - the ‘Finished’ message to send to the orchestrator

Trait Implementations§

Source§

impl Clone for Worker

Source§

fn clone(&self) -> Worker

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !Freeze for Worker

§

impl !RefUnwindSafe for Worker

§

impl Send for Worker

§

impl Sync for Worker

§

impl Unpin for Worker

§

impl !UnwindSafe for Worker

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more