-
Notifications
You must be signed in to change notification settings - Fork 51
chore(flagd): refactoring codebase into multiple classes #378
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
chore(flagd): refactoring codebase into multiple classes #378
Conversation
...ers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/strategy/ResolveFactory.java
Show resolved
Hide resolved
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/grpc/GrpcConnector.java
Outdated
Show resolved
Hide resolved
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/grpc/GrpcConnector.java
Outdated
Show resolved
Hide resolved
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/grpc/GrpcConnector.java
Outdated
Show resolved
Hide resolved
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/grpc/GrpcConnector.java
Outdated
Show resolved
Hide resolved
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/grpc/GrpcConnector.java
Outdated
Show resolved
Hide resolved
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/FlagResolution.java
Outdated
Show resolved
Hide resolved
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/FlagdProvider.java
Show resolved
Hide resolved
...rs/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/grpc/EventStreamObserver.java
Outdated
Show resolved
Hide resolved
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/grpc/GrpcConnector.java
Show resolved
Hide resolved
@@ -46,25 +55,20 @@ public void onError(Throwable t) { | |||
if (this.cache.getEnabled()) { | |||
this.cache.clear(); |
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.
I believe we should not bust the cache in case of error and instead use the latest known values until the stream is reconnected. This line basically prevents to do ANY flag evaluation if we cannot connect to flagd. IMHO we should still be able to resolve flags according to what we have in the cache instead of failing the gRPC resolution and use the default value.
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.
Added to #390
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.
The idea here is that a connection lost results in stale flags. And stale flags could result in inconsistent behavior. So I think we should keep this.
However, another option is to make this a configurable option
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.
The problem is we don't cache all values, we only cache static flags (flags without rules).
This puts us in a situation where we really can't evaluate all flags. If we were evaluating flags in memory, we could just have "STALE" flags, but with the RPC design, we simply can't evaluate dynamic flags at all.
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.
This screams for a configurable option as @Kavindu-Dodan suggests 🤔
I'll try to explain my thoughts: since values are static, I want to "remotely rewrite" the default value in the code. Hence, saving the last known values would allow me to evaluate things as the last point in time I had a connection to flagd.
For dynamic flags, failing and defaulting to the default value is fine since I cannot pass the ctx to flagd to evaluate the flags according to the rules.
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.
I can see how some people might be interested in this option. It's worth discussing, but it can't be done in isolation. We can talk about it (perhaps in a flagd discussion?) and add it to the doc so it can be implemented/scheduled in all flagd RPC providers.
cbcfba4
to
7227c2a
Compare
Signed-off-by: Giovanni Liva <[email protected]>
Signed-off-by: Giovanni Liva <[email protected]>
Signed-off-by: Giovanni Liva <[email protected]>
Signed-off-by: Giovanni Liva <[email protected]>
Signed-off-by: Giovanni Liva <[email protected]>
Signed-off-by: Giovanni Liva <[email protected]>
Signed-off-by: Giovanni Liva <[email protected]>
Signed-off-by: Giovanni Liva <[email protected]>
Signed-off-by: Giovanni Liva <[email protected]>
Signed-off-by: Giovanni Liva <[email protected]>
7227c2a
to
6be8c10
Compare
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/grpc/FlagResolution.java
Outdated
Show resolved
Hide resolved
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.
Approving with stated comments and fixes
Signed-off-by: Giovanni Liva <[email protected]>
Thanks @thisthat ! Looks much better IMO. |
…ure#378) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This PR
Related Issues
Fixes #365