Trait orchestrator::plugin::Plugin
source · pub trait Plugin<S: ExecutorGlobalState>: Sized + Send + Sync + 'static {
// Required methods
fn name(&self) -> &str;
fn desctiption(&self) -> &str;
// Provided methods
fn run(
self,
o: OrchestratorReference<S>,
should_stop: Arc<Notify>,
) -> impl Future<Output = ()> + Send + 'static { ... }
fn on_add<'a>(
&'a mut self,
o: &'a mut Orchestrator<S>,
) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync + 'static>>> + Send + 'a { ... }
}Expand description
Plugin interface:
contains name and description methods, and they are needed for visualizzation purpose.
The fondamental method is run, that takes an OrchestratorReference. It can gracefully shutdown all program by notifing “should_stop”
Then there is on_add, and is executed while the plugin is getting add.
Required Methods§
sourcefn desctiption(&self) -> &str
fn desctiption(&self) -> &str
Return a descriptionn of the Plugin. It should contain a list of the registered and activated Executors
Provided Methods§
sourcefn run(
self,
o: OrchestratorReference<S>,
should_stop: Arc<Notify>,
) -> impl Future<Output = ()> + Send + 'static
fn run( self, o: OrchestratorReference<S>, should_stop: Arc<Notify>, ) -> impl Future<Output = ()> + Send + 'static
Function called when the Plugin is runned (at the end of the init phase). it takes an OrchestratorReference, which permit almost complete control over the orchestrator, and a shared Notify. This notify should get called when a Plugin request an orchestrator shutdown.
sourcefn on_add<'a>(
&'a mut self,
o: &'a mut Orchestrator<S>,
) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync + 'static>>> + Send + 'a
fn on_add<'a>( &'a mut self, o: &'a mut Orchestrator<S>, ) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync + 'static>>> + Send + 'a
When the plugin gets added to the Orchestrator, this function gets called. It gives complete control on the unrunned executor. It should be used to register/activate executor, add other Plugins, add Exercise (discouraged)…