Sign in

    moonbitstack/mooncat/lifespan does not have a README file

    LifespanError

    pub suberror LifespanError {
    LifespanError(String)
    }

    Raised when the lifespan protocol stops the boot or reports a failed shutdown: the application sent lifespan.startup.failed or lifespan.shutdown.failed, or it raised under Lifespan::On. Carries the application's message.

    Driver

    pub struct Driver {
    state : Map[String, Json]
    // private fields
    }

    Drives an application's lifespan protocol (← uvicorn's LifespanOn).

    One invocation of the application runs under a Lifespan scope for the server's whole life: startup sends lifespan.startup and waits for the answer, shutdown sends lifespan.shutdown. state is the scope's namespace; the server gives every request scope a shallow copy, so what startup stores there reaches each request.

    mode is uvicorn's --lifespan: under Auto an application that fails on the lifespan scope, as one serving only HTTP does, is taken not to speak the protocol and the server carries on; under On that failure stops the boot; under Off nothing runs.

    Driver::shutdown

    async fn Driver::shutdown(self : Driver) -> Unit

    Run lifespan shutdown: send lifespan.shutdown and wait for the answer, unless the invocation has already ended. Raises LifespanError on lifespan.shutdown.failed, and on a failure of the application under On.

    Driver::spawn

    fn Driver::spawn(self : Driver, g :
    TaskGroup
    [Unit]) -> Unit

    Start the lifespan invocation as a task in g. It waits on receive() until startup and shutdown send it something; its failure is contained, and reported through them.

    Driver::startup

    async fn Driver::startup(self : Driver) -> Unit

    Run lifespan startup: send lifespan.startup and wait for the answer. Returns on lifespan.startup.complete, and when the application returns without answering. Raises LifespanError on lifespan.startup.failed, and on a failure of the application under On; under Auto such a failure means the application does not speak the protocol.

    Source Files