-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
src/frequenz/client/base/channel.py
Outdated
- 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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no docs?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
Updated to fix the typo. |
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 <[email protected]>
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 <[email protected]>
Add a new module
channel
with a function to parse URIs to creategrpclib
clientChannel
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.