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 parsing of gRPC channel URIs #51

Merged
merged 2 commits into from
May 14, 2024
Merged

Conversation

llucax
Copy link
Contributor

@llucax llucax commented May 8, 2024

Add a new module channel with a function to parse URIs to create grpclib client Channel instances. For now the URI provides only very basic options, but it can be extended in the future.

The main idea for this is to abstract ourselves from the channel class in the client, for one side to ease the transition to betterproto/grpclib but also because we will soon need an easy way to configure secure channels too, so just host/port won't be enough. Using URIs is pretty flexible as one can pass arbitrary options via query strings.

@llucax llucax requested a review from a team as a code owner May 8, 2024 15:43
@llucax llucax requested a review from shsms May 8, 2024 15:43
@llucax llucax self-assigned this May 8, 2024
@llucax llucax added this to the v0.4.0 milestone May 8, 2024
@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:code Affects the code in general labels May 8, 2024
@llucax llucax added the type:enhancement New feature or enhancement visitble to users label May 8, 2024
- If a query parameter is passed many times, the last value is used.
- The only supported query parameter is `ssl`, which must be a boolean value and
defaults to `false`.
- Bolean query parameters can be specified with the following values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boolean

from grpclib.client import Channel


def _to_bool(value: str) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's private and trivial, I intentionally left it without docs, but I can add some if you think it should have some.

Copy link
Contributor

@Marenz Marenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

@llucax
Copy link
Contributor Author

llucax commented May 14, 2024

Updated to fix the typo.

@llucax llucax enabled auto-merge May 14, 2024 07:24
This new module provides a function to parse URIs to create `grpclib`
client `Channel` instances. For now the URI provides only very basic
options, but it can be extended in the future.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
This is already checked by `mypy`, and `pylint` is not as smart as `mypy`
to understand types, so it suffers from some false positives (for
example after asserting that an object `isinstance` of a type, `pylint`
still complains that the object don't have the attributes of the type).

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
@llucax llucax added this pull request to the merge queue May 14, 2024
Merged via the queue into frequenz-floss:v0.x.x with commit 63d0589 May 14, 2024
14 checks passed
@llucax llucax deleted the chan-uri branch May 14, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part:code Affects the code in general part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) type:enhancement New feature or enhancement visitble to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants