grpc / grpc/grpc-rust

Shared UDS channel via static gRPC client

Open
#1,623 1 comment 2 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
I want the UDS channel can be reused for multiple gRPC request via bellow code:

```
static MY_CLIENT: OnceCell> = OnceCell::const_new();
async fn get_client(my_uds_path: String) -> MyClient {
let uds_path = my_uds_path.parse::().unwrap();
MY_CLIENT.get_or_init(|| async {
let channel = Endpoint::try_from("http://[::]:0")
.unwrap()
.keep_alive_while_idle(true)
.connect_with_connector(service_fn(move |_: Uri| {
UnixStream::connect(uds_path.to_string())
}))
.await
.unwrap();

MyClient::new(channel.clone())
})
.await.clone()
}
```

### Crates

### Motivation

I have multiple kind of gRPC requests to be sent, but when I call above static client defined in gRPC and intialized via channel,
it failed by:
called `Result::unwrap()` on an `Err` value: Status { code: Unknown, message: "Service was not ready: transport error", source: None }

### Proposal

### Alternatives

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.