moonbitstack/moonzero/service does not have a README file

    Service

    pub(all) struct Service {
    name : String
    start : async () -> Unit
    }

    One service in a group: a name, so a failure can say which one it was, and the body that runs it until it is cancelled.

    Service::new

    fn Service::new(name : String, start : async () -> Unit) -> Service

    A named service.

    ServiceGroup

    pub struct ServiceGroup {
    services : Array[Service]
    }

    Several services run as one process (← go-zero's service.Group).

    Every service is a task that runs until it returns or is cancelled, so a server loop and a background refresher share one lifetime: when the first fails, the rest are cancelled and the failure reaches the caller rather than leaving half a process running.

    ServiceGroup::add

    fn ServiceGroup::add(self : ServiceGroup, service : Service) -> Unit

    Add a service to the group.

    ServiceGroup::add_fn

    fn ServiceGroup::add_fn(self : ServiceGroup, name : String, start : async () -> Unit) -> Unit

    Add a service under name.

    ServiceGroup::names

    fn ServiceGroup::names(self : ServiceGroup) -> Array[String]

    The names of the services in the group, in the order they were added.

    ServiceGroup::new

    A group with nothing in it.

    ServiceGroup::start

    async fn ServiceGroup::start(self : ServiceGroup) -> Unit

    Run every service concurrently and return when all of them have finished.

    A service that fails cancels the others, so a group either runs or reports what stopped it — it never leaves a member behind.

    Source Files