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

Add a way to test/inspect server and router build/configuration #1679

Open
egtwp opened this issue Apr 10, 2024 · 0 comments
Open

Add a way to test/inspect server and router build/configuration #1679

egtwp opened this issue Apr 10, 2024 · 0 comments

Comments

@egtwp
Copy link

egtwp commented Apr 10, 2024

Feature Request

Motivation

For example, let's say I want to parse a configuration file to build my tonic server:

   // Let's exclude the file parsing code since it's not the focus here
   struct MyTonicConfig {
        http1: bool,
        concurrency_limit: Option<usize>,
        keep_alive: Option<std::time::Duration>,
    }

    fn build_tonic_by_config(config: MyTonicConfig) -> tonic::transport::Server {
        let mut my_tonic_server = Server::builder();

        if config.http1 {
            my_tonic_server = my_tonic_server.accept_http1(true);
        }

        if let Some(concurrency_limit) = config.concurrency_limit {
            my_tonic_server = my_tonic_server.concurrency_limit_per_connection(concurrency_limit);
        }

        my_tonic_server = my_tonic_server.http2_keepalive_timeout(config.keep_alive);

        my_tonic_server
    }

I would like to be able to inspect the resulting tonic server to be sure my code is working as expected, but I can't find any getter for tonic::transportation::Server fields.

Similar, but I think more complicated, scenario I think is applicable for Router and Routes.

Proposal

The simplest solution I can think is to add getters for tonic::transportaion:Server

Alternatives

  1. Implement an "expect" like method that can compare tonic::transportaion:Server fields value with given test value.
  2. Implement PartialEq/Eq for tonic::transportaion:Server
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