Skip to content
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

feat: add TransactionContext #283

Conversation

kevinschoonover
Copy link
Contributor

@kevinschoonover kevinschoonover commented Aug 30, 2024

This PR

  • Adds backwards compatible, basic implementation of 'TransactionContext'

The functions that are important are

WithTranscationContext(ctx, EvaluationContext)
TransactionContext(ctx)

Related Issues

#256

Notes

For next steps,

  • I see the API suggested in [FEATURE] Implement transaction context #256 is to remove the local evalCtx which would make the API much cleaner in my opinion, but I am not sure what is the process for breaking changes
  • I am also not sure what the right behavior of merging should be from the API's perspective if they run WithTransactionContext multiple times. My guess is we should expect the user to handle this on their end, but would be interested in opinions on if WithTransactionContext should merge existing TransactionContexts

How to test

I updated the associated tests for merging order / evaluation. Please let me know if any other tests will be helpful!

@kevinschoonover kevinschoonover requested a review from a team as a code owner August 30, 2024 17:55
Signed-off-by: Kevin Schoonover <me@kschoon.me>
@kevinschoonover kevinschoonover force-pushed the kevinschoonover/transcation-context branch from 36ff6ae to 4d08b89 Compare August 30, 2024 17:55
Copy link

codecov bot commented Aug 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.12%. Comparing base (ad9db29) to head (fe4b61d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #283      +/-   ##
==========================================
+ Coverage   81.92%   82.12%   +0.20%     
==========================================
  Files          10       10              
  Lines         979      990      +11     
==========================================
+ Hits          802      813      +11     
  Misses        156      156              
  Partials       21       21              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@beeme1mr
Copy link
Member

Hey @kevinschoonover, could you please update the readme to include a section about this? Please follow the template found here. Thanks!

@beeme1mr
Copy link
Member

I am also not sure what the right behavior of merging should be from the API's perspective if they run WithTransactionContext multiple times. My guess is we should expect the user to handle this on their end, but would be interested in opinions on if WithTransactionContext should merge existing TransactionContexts

Yes, I agree. Currently, all implementations override existing transaction context, but adding another method that merges would be useful.

Signed-off-by: Kevin Schoonover <me@kschoon.me>
Signed-off-by: Kevin Schoonover <me@kschoon.me>
@kevinschoonover
Copy link
Contributor Author

Hey @kevinschoonover, could you please update the readme to include a section about this? Please follow the template found here. Thanks!

Done!

I am also not sure what the right behavior of merging should be from the API's perspective if they run WithTransactionContext multiple times. My guess is we should expect the user to handle this on their end, but would be interested in opinions on if WithTransactionContext should merge existing TransactionContexts

Yes, I agree. Currently, all implementations override existing transaction context, but adding another method that merges would be useful.

Added a MergeTransactionContext function which should solve this case. Let me know if there is anything else I can update!

Copy link
Member

@beeme1mr beeme1mr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks! I'll defer the final review to a Go expert but it looks good to me.

Signed-off-by: Kevin Schoonover <me@kschoon.me>
Copy link

@evan-bradley evan-bradley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. All my suggestions are non-blocking.

openfeature/internal/context_key.go Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
openfeature/evaluation_context.go Show resolved Hide resolved
openfeature/evaluation_context_test.go Outdated Show resolved Hide resolved
Copy link
Member

@lukas-reining lukas-reining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good to me!

kevinschoonover and others added 2 commits September 8, 2024 07:59
Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
Signed-off-by: Kevin Schoonover <schoonoverkevinm@gmail.com>
Signed-off-by: Kevin Schoonover <me@kschoon.me>
@kevinschoonover kevinschoonover force-pushed the kevinschoonover/transcation-context branch from 55dad60 to b28ad6f Compare September 8, 2024 15:08
@beeme1mr beeme1mr merged commit 788151d into open-feature:main Sep 9, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants