grpc / grpc/grpc-rust

Single Threaded Tonic Client/Server

Open
#2,790 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12.5k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
24

Description

## 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/grpc/grpc-rust/issues/2171](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
how to generate trait with #[async_trait(?Send)] (closed): [https://github.com/grpc/grpc-rust/issues/844](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
feat: Support thread-local functionality (closed PR): [https://github.com/grpc/grpc-rust/pull/1505](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)
add Single-threaded runtime (closed): [https://github.com/grpc/grpc-rust/issues/784](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)

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).

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the client and server code under src, focusing on the Send + Sync requirements and the async_trait usage mentioned in the proposal. Compare the prior discussions and closed PR about thread-local functionality, then define what complete single-threaded client and server support would require.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.