Skip to main content

Service

Trait Service 

Source
pub trait Service: Send + Sync {
    // Required methods
    fn collect_resources(&self, resource_batch: &mut ResourceBatch);
    fn deploy<'life0, 'life1, 'async_trait>(
        &'life0 self,
        resource_result: &'life1 Arc<ResourceResult>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn ready<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn start<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stop<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}

Required Methods§

Source

fn collect_resources(&self, resource_batch: &mut ResourceBatch)

Makes requests for physical resources server ports that this service needs to run. This should not recursively call collect_resources on the host, since we guarantee that collect_resources is only called once per host.

This should also perform any “free”, non-blocking computations (compilations), because the deploy method will be called after these resources are allocated.

Source

fn deploy<'life0, 'life1, 'async_trait>( &'life0 self, resource_result: &'life1 Arc<ResourceResult>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Connects to the acquired resources and prepares the service to be launched.

Source

fn ready<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Launches the service, which should start listening for incoming network connections. The service should not start computing at this point.

Source

fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Starts the service by having it connect to other services and start computations.

Source

fn stop<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stops the service by having it disconnect from other services and stop computations.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§