-
Notifications
You must be signed in to change notification settings - Fork 12
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: implement batch map #133
Conversation
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
pkg/batchmapper/service.go
Outdated
if len(responses.Items()) != len(datums) { | ||
errMsg := "batchMapFn: mismatch between length of batch requests and responses" | ||
log.Panic(errMsg) | ||
} |
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.
is it possible to avoid panic?
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 choose either to panic or send an error back(numa will be restarted in both cases), based on an earlier discussion with @vigith we thought that having a panic here would be a clear indication for the user that there is an issue. And as this in a mismatch in the implementation from the user side for not providing equal number of responses, the reason for restarts and error gives better clarity there.
But this is our decision on how do we want to keep the behavior in such scenarios.
@vigith @whynowy Any preferences?
Signed-off-by: Sidhant Kohli <[email protected]>
Signed-off-by: Sidhant Kohli <[email protected]>
Signed-off-by: Sidhant Kohli <[email protected]>
Signed-off-by: a3hadi <[email protected]> Signed-off-by: Sidhant Kohli <[email protected]>
Signed-off-by: Sidhant Kohli <[email protected]>
Signed-off-by: Sidhant Kohli <[email protected]>
Signed-off-by: Sidhant Kohli <[email protected]>
Signed-off-by: Sidhant Kohli <[email protected]>
func (u *BatchMapFnServerErrTest) Context() context.Context { | ||
return u.ctx | ||
} | ||
|
||
func TestService_BatchMapFn(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
handler BatchMapper | ||
input []*batchmappb.BatchMapRequest | ||
expected []*batchmappb.BatchMapResponse | ||
expectedErr bool | ||
}{ |
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 add a test to cover the error/panic case inside the user code?
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.
In the current setup, this is difficult to test via UT directly. I tried to add the test there but the assert.Panics (which internally uses recover) was not able to catch it as the panic is invoked from within another goroutine. Would need to research more on how can we cover something like this. In python i'm able to mock the panic and test which wasn't working out here.
I tried few manual scenarios to induce such panics which were working fine.
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!
Fixes #1786