-
Notifications
You must be signed in to change notification settings - Fork 43
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
Use project as targeting key, propagate message context through entity evaluation #3827
Merged
evankanderson
merged 3 commits into
mindersec:main
from
evankanderson:message-eval-context
Jul 15, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,10 +39,12 @@ func fromContext(ctx context.Context) openfeature.EvaluationContext { | |
// Note: engine.EntityFromContext is best-effort, so these values may be zero. | ||
ec := engcontext.EntityFromContext(ctx) | ||
return openfeature.NewEvaluationContext( | ||
jwt.GetUserSubjectFromContext(ctx), | ||
ec.Project.ID.String(), | ||
map[string]interface{}{ | ||
"project": ec.Project.ID.String(), | ||
"project": ec.Project.ID.String(), | ||
// TODO: is this useful, given how provider names are used? | ||
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. IMHO we should consider removing it, but I don't have strong feelings about it right now. 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 think you're probably right. |
||
"provider": ec.Provider.Name, | ||
"user": jwt.GetUserSubjectFromContext(ctx), | ||
}, | ||
) | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If I got this right, you're still waiting for
Done()
on what was originally theterminationcontext
, but keep track of all downstream contexts to cancel them as well, right?If yes, was this source of some sort of bug?
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.
What I really want is
Context.TerminateOnAdditionalContext(ctx, additional)
. But that doesn't exist.The problem is that
handleEntityEvent
is (for performance) extracting the event processing out of the watermill message lifecycle, but we still want to be able to cancel message processing during process shutdown.The previous way we were doing this was to basically take the background context of the server and sub it in for the message context, but that means that we're losing all the message context in the event handler. The new pattern is to use
Context.WithoutCancel
to escape from the cancellation of the Watermill event handler (because it only allows one message in flight), but then store the cancels for this loop.If we didn't have the performance problem with Watermill, we still might want to be able to early-terminate the in-flight event handling when the server shuts down, but we'd do that by passing the termination context to Watermill and have it cancel all the contexts. But when we call
WithoutCancel
, we end up putting that work on ourselves.(I'm also back-intuiting some of this from #1654)