shuttle_runtime

Trait Service

Source
pub trait Service: Send {
    // Required method
    fn bind<'async_trait>(
        self,
        addr: SocketAddr,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

The core trait of the Shuttle platform. Every service deployed to Shuttle needs to implement this trait.

An Into<Service> implementor is what is returned in the shuttle_runtime::main macro in order to run it on the Shuttle servers.

Required Methods§

Source

fn bind<'async_trait>( self, addr: SocketAddr, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,

This function is run exactly once on startup of a deployment.

The passed SocketAddr receives proxied HTTP traffic from you Shuttle subdomain (or custom domain). Binding to the address is only relevant if this service is an HTTP server.

Implementors§