Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared UDS channel via static gRPC client #1623

Open
hairongchen opened this issue Feb 5, 2024 · 0 comments
Open

Shared UDS channel via static gRPC client #1623

hairongchen opened this issue Feb 5, 2024 · 0 comments

Comments

@hairongchen
Copy link

Feature Request

I want the UDS channel can be reused for multiple gRPC request via bellow code:

static MY_CLIENT: OnceCell<MyClient<Channel>> = OnceCell::const_new();
async fn get_client(my_uds_path: String) -> MyClient<Channel> {
    let uds_path = my_uds_path.parse::<Uri>().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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant