-
Notifications
You must be signed in to change notification settings - Fork 18
feat: add grpc sync flag store #84
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
Changes from all commits
1899571
2bfffe6
fd8fe11
17e8ce8
378ccc9
054e5af
b899d82
19a29e5
cc14759
8088a6f
e86984b
b8fa382
80419a7
5782c09
1f82462
1b25540
f5e89c0
45e3739
e9cd2ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
services: | ||
flagd: | ||
build: | ||
context: test-harness | ||
dockerfile: flagd/Dockerfile | ||
ports: | ||
- 8013:8013 | ||
flagd-unstable: | ||
build: | ||
context: test-harness | ||
dockerfile: flagd/Dockerfile.unstable | ||
ports: | ||
- 8014:8013 | ||
flagd-sync: | ||
build: | ||
context: test-harness | ||
dockerfile: sync/Dockerfile | ||
ports: | ||
- 9090:9090 | ||
flagd-sync-unstable: | ||
build: | ||
context: test-harness | ||
dockerfile: sync/Dockerfile.unstable | ||
ports: | ||
- 9091:9090 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make sure this file is excluded from published package. We can do so from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Checking this now it also includes
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd have to check the generated build to confirm. If you can please make this change in a separate PR. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ def __init__( # noqa: PLR0913 | |
port: typing.Optional[int] = None, | ||
tls: typing.Optional[bool] = None, | ||
timeout: typing.Optional[int] = None, | ||
retry_backoff_seconds: typing.Optional[float] = None, | ||
selector: typing.Optional[str] = None, | ||
resolver_type: typing.Optional[ResolverType] = None, | ||
offline_flag_source_path: typing.Optional[str] = None, | ||
offline_poll_interval_seconds: typing.Optional[float] = None, | ||
|
@@ -42,6 +44,14 @@ def __init__( # noqa: PLR0913 | |
env_or_default("FLAGD_TLS", False, cast=str_to_bool) if tls is None else tls | ||
) | ||
self.timeout = 5 if timeout is None else timeout | ||
self.retry_backoff_seconds: float = ( | ||
float(env_or_default("FLAGD_RETRY_BACKOFF_SECONDS", 2.0)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but then it gives me this: After fighting with mypy a bit I realised that pulling the cast outside of the function is the cleanest way to have clean typing. I would instead suggest refactoring to remove this helper function everywhere and just use the python libraries directly. This abstraction doesn't add too much if you ask me:
vs
|
||
if retry_backoff_seconds is None | ||
else retry_backoff_seconds | ||
) | ||
self.selector = ( | ||
env_or_default("FLAGD_SELECTOR", None) if selector is None else selector | ||
) | ||
self.resolver_type = ( | ||
ResolverType(env_or_default("FLAGD_RESOLVER_TYPE", "grpc")) | ||
if resolver_type is None | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"""Client and server classes corresponding to protobuf-defined services.""" | ||
import grpc | ||
|
||
from flagd.evaluation.v1 import evaluation_pb2 as flagd_dot_evaluation_dot_v1_dot_evaluation__pb2 | ||
from . import evaluation_pb2 as flagd_dot_evaluation_dot_v1_dot_evaluation__pb2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these changes automated after grpc code generation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, I actually didn't notice that script. When I try to run it I get this file not found error, does it need to be fixed and maybe documented in the contributing guide?
|
||
|
||
|
||
class ServiceStub(object): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,5 @@ | ||
import typing | ||
|
||
from typing_extensions import Protocol | ||
|
||
from openfeature.evaluation_context import EvaluationContext | ||
from openfeature.flag_evaluation import FlagResolutionDetails | ||
|
||
from .grpc import GrpcResolver | ||
from .in_process import InProcessResolver | ||
|
||
|
||
class AbstractResolver(Protocol): | ||
def shutdown(self) -> None: ... | ||
|
||
def resolve_boolean_details( | ||
self, | ||
key: str, | ||
default_value: bool, | ||
evaluation_context: typing.Optional[EvaluationContext] = None, | ||
) -> FlagResolutionDetails[bool]: ... | ||
|
||
def resolve_string_details( | ||
self, | ||
key: str, | ||
default_value: str, | ||
evaluation_context: typing.Optional[EvaluationContext] = None, | ||
) -> FlagResolutionDetails[str]: ... | ||
|
||
def resolve_float_details( | ||
self, | ||
key: str, | ||
default_value: float, | ||
evaluation_context: typing.Optional[EvaluationContext] = None, | ||
) -> FlagResolutionDetails[float]: ... | ||
|
||
def resolve_integer_details( | ||
self, | ||
key: str, | ||
default_value: int, | ||
evaluation_context: typing.Optional[EvaluationContext] = None, | ||
) -> FlagResolutionDetails[int]: ... | ||
|
||
def resolve_object_details( | ||
self, | ||
key: str, | ||
default_value: typing.Union[dict, list], | ||
evaluation_context: typing.Optional[EvaluationContext] = None, | ||
) -> FlagResolutionDetails[typing.Union[dict, list]]: ... | ||
|
||
from .protocol import AbstractResolver | ||
|
||
__all__ = ["AbstractResolver", "GrpcResolver", "InProcessResolver"] |
Uh oh!
There was an error while loading. Please reload this page.