Skip to content

Should ServiceExt::serve() return after initialization? #1143

Description

@the-isz

Looking at examples/servers/src/counter_stdio.rs (but other examples and README.md use the same code):

let service = Counter::new().serve(stdio()).await.inspect_err(|e| {
    tracing::error!("serving error: {:?}", e);
})?;

service.waiting().await?;

The above code implies to me that ServiceExt::serve() returns either a RunningService or an initialization error after being awaited.
After the successful initialization I expect that I can do other stuff and then eventually wait for the service to shut down (e.g. via the second line).

However, any code I add after the first line is never reached.
So I think something is wrong here.

Either I'm misunderstanding the API and ServiceExt::serve() is not supposed to return after initialization.
But then I wonder why we even have the second line in the example and how I'm supposed to do other (asynchronous) stuff after starting the service.

Or this is a bug and ServiceExt::serve() is supposed to return after initialization.

Thank you for your help!
I'm really impressed by this package and glad it sees so much development!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions