feat: make use of flagd-selector header in RPC mode#396
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for flagd selectors in the gRPC resolver by appending the flagd-selector metadata header to both unary and event stream calls when configured, and includes unit tests for unary calls. The feedback recommends updating GrpcMultiCallableArgs in types.py to avoid type-checking failures, importing the FLAGD_SELECTOR_HEADER constant in tests to avoid hardcoding, and adding test coverage for the event stream (listen) code path.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #396 +/- ##
==========================================
+ Coverage 94.20% 96.28% +2.08%
==========================================
Files 31 47 +16
Lines 1070 1750 +680
==========================================
+ Hits 1008 1685 +677
- Misses 62 65 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
RPC resolver now attaches the `flagd-selector` gRPC metadata header on every unary call and on the EventStream when a selector is configured, so the flagd server can serve the requested flag set. Brings the Python RPC resolver to parity with the Java and JS providers. Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
… args helper Reduces listen() complexity below ruff C901 threshold while keeping the flagd-selector header wiring intact. Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
The flagd evaluation v2 generated stubs require grpcio>=1.81.0 (RuntimeError at import time otherwise). The pyproject constraint and lockfile were still pinned to 1.80.0, breaking CI on main. Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
- types.py: metadata is now variadic tuple[tuple[str, str], ...] to allow >1 entry and satisfy mypy.\n- tests: import FLAGD_SELECTOR_HEADER from the resolver instead of hardcoding, and add coverage for the EventStream listen() path (both with and without selector). Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
07be9e3 to
7ca797b
Compare
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the grpcio dependency and adds support for passing a selector header (flagd-selector) in gRPC metadata for both unary calls and event streams in the flagd provider, along with comprehensive unit tests. The feedback suggests a minor improvement in GrpcResolver.__init__ to use the config parameter directly instead of self.config to prevent potential initialization issues and maintain consistency.
…rovider/flagd/resolvers/grpc.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
flagd-selectorgRPC metadata header, but the RPC resolver did not. This PR wires it up: the RPC resolver now sends the header on every unary call and on theEventStreamwhen a selector is configured, so the flagd server can serve the requested flag set.We missed the RPC mode in: #320 (closed #319).