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
impl Worker
Sourcepub async fn new(args: &ArgMatches) -> Result<Worker, Box<dyn Error>>
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
Sourceasync fn connect(
address: String,
fqdn: Option<&String>,
) -> Result<ControllerClient<Channel>, Box<dyn Error>>
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);
Sourcefn init(&mut self, task: Task, worker_id: u16, abort_s: Option<Arc<AtomicBool>>)
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
Sourceasync fn connect_to_server(&mut self) -> Result<(), Box<dyn Error>>
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.
Sourceasync fn send_result_to_server(
&mut self,
task_result: TaskResult,
) -> Result<(), Box<dyn Error>>
async fn send_result_to_server( &mut self, task_result: TaskResult, ) -> Result<(), Box<dyn Error>>
Send a TaskResult to the orchestrator
Sourceasync fn measurement_finish_to_server(
&mut self,
finished: Finished,
) -> Result<(), Box<dyn Error>>
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§
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered
].