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(pubsub/pstest): add channel to support user-defined publish responses #4251
feat(pubsub/pstest): add channel to support user-defined publish responses #4251
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, with a minor caveat which may or may not be relevant given my lack of experience with the p/s fake.
@@ -613,6 +658,15 @@ func (s *GServer) Publish(_ context.Context, req *pb.PublishRequest) (*pb.Publis | |||
if top == nil { | |||
return nil, status.Errorf(codes.NotFound, "topic %q", req.Topic) | |||
} | |||
|
|||
if !s.autoPublishResponse { | |||
r := <-s.publishResponses |
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.
Unclear if it matters, but do you want blocking behavior here, or should it emit an error in the case of some kind of timeout via a select loop or similar?
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.
I want blocking behavior, but could be convinced to add a timeout/error in the future.
🤖 I have created a release \*beep\* \*boop\* --- ## [1.12.0](https://www.github.com/googleapis/google-cloud-go/compare/pubsub/v1.11.0...pubsub/v1.12.0) (2021-06-23) ### Features * **pubsub/pstest:** add channel to support user-defined publish responses ([#4251](https://www.github.com/googleapis/google-cloud-go/issues/4251)) ([e1304f4](https://www.github.com/googleapis/google-cloud-go/commit/e1304f435fed4a767f4a652f32f1386979ff794f)) ### Bug Fixes * **pubsub:** fix memory leak issue in publish scheduler ([#4282](https://www.github.com/googleapis/google-cloud-go/issues/4282)) ([22ffc18](https://www.github.com/googleapis/google-cloud-go/commit/22ffc18e522c0f943db57f8c943e7356067bedfd)) This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Taken from the Java fake publisher service, these changes improves testing by allowing users to specify
PublishResponses
that the fake server will return forPublish
calls.This is implemented with a buffered publishResponses channel, that users can add to by disabling automatic publish responses (the current behavior) and calling
AddPublishResponse
.Lastly, the default buffered channel size is 100 (an arbitrary number suitable for testing). If the size needs to be increased, or you want to reset the publish queue, call
ResetPublishResponses
.The changes in this PR will be used to help test publisher flow control.