Skip to content

Single Threaded Tonic Client/Server #2790

Description

@artsiomkaltovich

Feature Request

Motivation

Tonic requires Send + Sync for the client code, that make it hard to introduce to single-threaded async code. Not every service should be multi-threaded and now adding tonic in single threaded code could be painful.
This topic was raised several times:

Single threaded server example with async_trait(?Send) (open): https://github.com//issues/2171
how to generate trait with #[async_trait(?Send)] (closed): https://github.com//issues/844
feat: Support thread-local functionality (closed PR): https://github.com//pull/1505
add Single-threaded runtime (closed): https://github.com//issues/784

however, it wasn't fully implemented yet.

Proposal

I think ability to run tonic natively in single-threaded without send+sync addition would benefit the community a lot.

To be honest I haven't check the src yet. There were suggestions to replace async_trait with async_trait(?Send) another approach is code split and introducing local versions for code (with/or without feature flag).

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