-
Notifications
You must be signed in to change notification settings - Fork 453
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
Add RequireNoWait header #3502
Add RequireNoWait header #3502
Conversation
c0d9cb7
to
08d0a57
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.
LGTM with a couple of nits, but you may want someone more familiar with these paths have a look 👍
@@ -244,6 +244,7 @@ func FromRPCFetchTaggedRequest( | |||
StartInclusive: start, | |||
EndExclusive: end, | |||
RequireExhaustive: req.RequireExhaustive, | |||
RequireNoWait: req.RequireNoWait, |
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: can we get some tests for FromRPCFetchTaggedRequest
->ToRPCFetchTaggedRequest
and back cases to verify we don't drop these params? Same with the other convert func
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.
There's an integration test thankfully here, but agreed unit tests should also be added.
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 unit test.
@@ -37,13 +37,16 @@ func TestFixedPermits(t *testing.T) { | |||
require.NoError(t, err) | |||
expectedP := NewPermit(1, iOpts) | |||
expectedP.(*permit).refCount.Inc() | |||
p, err := fp.Acquire(ctx) | |||
r, err := fp.Acquire(ctx) | |||
p := r.Permit |
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: check error first in case this is nil, same for the other calls in this file
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.
Done.
@@ -104,6 +104,10 @@ const ( | |||
// ensure M3 returns an error if the results set is not exhaustive. | |||
LimitRequireExhaustiveHeader = M3HeaderPrefix + "Limit-Require-Exhaustive" | |||
|
|||
// LimitRequireNoWaitHeader is the M3 header that ensures | |||
// M3 returns an error if query execution must wait for permits. | |||
LimitRequireNoWaitHeader = M3HeaderPrefix + "Limit-Require-NoWait" |
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: Limit-Require-No-Wait
to keep consistency?
return v, nil | ||
} | ||
|
||
if str := req.FormValue("requireNoWait"); str != "" { |
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: const this out?
WaitedSeriesRead int `json:"waitedSeriesRead"` | ||
} | ||
|
||
// Any returns whether any waiting occurred. |
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: maybe Waited
has a little more context?
@@ -58,6 +67,15 @@ type Permits interface { | |||
Release(permit Permit) | |||
} | |||
|
|||
// AcquireResult contains metadata about acquiring a permit. |
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.
meganit: not quite metadata since it contains the permit itself
What this PR does / why we need it:
Add optional header to require that permits will never wait.
Special notes for your reviewer:
Does this PR introduce a user-facing and/or backwards incompatible change?:
Does this PR require updating code package or user-facing documentation?: