-
Notifications
You must be signed in to change notification settings - Fork 118
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
Allow to set the decisionID from an external function #516
Allow to set the decisionID from an external function #516
Conversation
bfa0bda
to
67beeaf
Compare
67beeaf
to
35a961a
Compare
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.
Thanks for working on this @Pushpalanka! The changes lgtm. Just few comments below and we can then get this in.
envoyauth/response.go
Outdated
@@ -34,14 +34,24 @@ type StopFunc = func() | |||
// TransactionCloser should be called to abort the transaction | |||
type TransactionCloser func(ctx context.Context, err error) error | |||
|
|||
// An Opt allowing externally setting the decision ID | |||
type Opt func(*EvalResult) |
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.
Nit: do we need to define this?
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.
We can remove it. Thanks for the suggestion.
envoyauth/response.go
Outdated
// NewEvalResult creates a new EvalResult and a StopFunc that is used to stop the timer for metrics | ||
func NewEvalResult() (*EvalResult, StopFunc, error) { | ||
func NewEvalResult(opts ...Opt) (*EvalResult, StopFunc, error) { |
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.
Can we do something like:
func NewEvalResult(opts ...func(*EvalResult)) (*EvalResult, StopFunc, error)
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.
Yes, improved.
7e0fc92
to
3635f3f
Compare
Signed-off-by: Pushpalanka Jayawardhana <pushpalanka.jayawardhana@zalando.de>
3635f3f
to
b01d47f
Compare
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.
Thanks @Pushpalanka!
Thanks @ashutosh-narkar for your support as well. :) |
Short description
An improvement to allow sending the decision ID from outside avoiding the default UUID generation here
Expected behavior
Suggesting improvement will allow passing a function from outside which can operate on the result. Current behavior of the default UUID generation is left intact, unless the function set a decision ID.
Additional context
In a benchmark test we noticed the UUID generation is comparatively costly. (Below image shows a branch of it.)
Hence it will benefit if we can send an externally generated ID and set it here, avoiding the costly operation.
CC: @mjungsbluth