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

Dynamically named services #1667

Open
lemma105 opened this issue Mar 28, 2024 · 0 comments
Open

Dynamically named services #1667

lemma105 opened this issue Mar 28, 2024 · 0 comments

Comments

@lemma105
Copy link

Feature Request

Currently the NamedService trait assumes that codegen from Prost is used to generate at compile time a const field that has a service name. This trait must be implemented on a service in order for the router to accept it (add_service in router.rs requires the NamedService trait).

This prevents the creation of services with names not known at compile time.

Motivation

I am creating an IDL agnostic server, using FFI to bridge to C++ which will handle the payload as the server is unable to serialize or deserialize it. In this scheme, the C++ client code will register methods onto a service with callbacks. Since the server will not know at compile time what the services it will be running are called, I currently must use a single placeholder service name.

Proposal

pub trait NamedService {
    const NAME: &'static str;
}

Needs to shift to something more like:

pub trait NamedService {
    fn get_name(self) -> &str;
}

And the subsequent internal modifications to both Tonic and Prost to support this need implemented.

I am new to Rust and not confident enough to implement this publicly. Suggestions and feedback welcomed.

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