-
Notifications
You must be signed in to change notification settings - Fork 163
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
messenger: Add handler decorator that is resource aware #2555
messenger: Add handler decorator that is resource aware #2555
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.
Reviewed 3 of 3 files at r1.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @lukedirtwalker)
go/lib/infra/common.go, line 251 at r1 (raw file):
// ResourceHealth indicates the health of a resource. A resource could for example be a database. // The resource health can be registered on the messenger, if any resource is not healthy it will
Change the "resource health can be registered on the messenger" part to instead mention the handler decorator.
go/lib/infra/common.go, line 332 at r1 (raw file):
// RegisterResource registers the given resource with the messenger. If the resource is not // healthy the messenger replies to all requests with an error. RegisterResource(resource ResourceHealth)
This is no longer needed.
go/lib/infra/common_test.go, line 54 at r1 (raw file):
rHandler := infra.NewResourceAwareHandler(handler, &mockResource{name: "tstFail", healthy: false}) rwMock := mock_infra.NewMockResponseWriter(ctrl) ctx := infra.NewContextWithResponseWriter(context.TODO(), rwMock)
Use context.Background()
here instead, it will stay out of code grep
s that search for unfinished context implementations.
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.
Reviewable status: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @scrye)
go/lib/infra/common.go, line 251 at r1 (raw file):
Previously, scrye (Sergiu Costea) wrote…
Change the "resource health can be registered on the messenger" part to instead mention the handler decorator.
Done.
go/lib/infra/common.go, line 332 at r1 (raw file):
Previously, scrye (Sergiu Costea) wrote…
This is no longer needed.
Done.
go/lib/infra/common_test.go, line 54 at r1 (raw file):
Previously, scrye (Sergiu Costea) wrote…
Use
context.Background()
here instead, it will stay out of codegrep
s that search for unfinished context implementations.
Done.
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.
Reviewed 2 of 2 files at r2.
Reviewable status:complete! all files reviewed, all discussions resolved
go/lib/infra/common.go, line 251 at r2 (raw file):
// ResourceHealth indicates the health of a resource. A resource could for example be a database. // The resource health can be added to a handler, so that the handler only replies if all it's
since this needs a rebase anyway :P, it's -> its.
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.
Reviewed 1 of 1 files at r3.
Reviewable status:complete! all files reviewed, all discussions resolved
If a resource is not healthy the handler should not be executed, instead an error should be returned.
33eeafe
to
fb67da4
Compare
If a resource is not healthy the handler should not be executed, instead an error should be returned.
This can be used to make handlers resource aware so that they don't execute when e.g. a database is not available.
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)