Skip to content
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

Adds a factory for building ResponseProcessor. #663

Merged
merged 1 commit into from
Apr 6, 2018

Conversation

archolewa
Copy link
Contributor

-- We would like to do a little bit of Druid error analysis to extract
some more illuminating error codes out of some of Druid's 500's. The
error callback is controlled by the ResponseProcessor.

-- Unfortunately, the ResponseProcessor can't be injected directly
because it depends on the DataApiRequest, which is built directly in
each request. So instead we wrap the creation of ResponseProcessor in
a factory that can be injected.

Copy link
Contributor

@QubitPi QubitPi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are pretty good. Prob. some minor issues

@@ -172,7 +176,8 @@ public DataServlet(
BroadcastChannel<String> preResponseStoredNotifications,
HttpResponseMaker httpResponseMaker,
ResponseFormatResolver formatResolver,
DataApiRequestFactory dataApiRequestFactory
DataApiRequestFactory dataApiRequestFactory,
ResponseProcessorFactory responseProcessorFactory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are changing contract of this method and there are possibilities of extending DataServlet in downstream projects, shall we crate a new constructor and deprecate this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't been doing that for the DataServlet. And we could, but seeing as how
we always add something to this constructor whenever we need to add something
new to inject, DataServlet would very quickly become very noisy.

Also, although it is technically possible to override the DataServlet, I think
that's sufficiently weird and rare enough that having hordes of giant
deprecated constructors running around would do more harm than good.

Especially since this is an easy enough thing to fix.

* @return A class that implements {@link ResponseProcessorFactory}.
*/
protected Class<? extends ResponseProcessorFactory> buildResponseProcessorFactory() {
return ResultSetResponseProcessorFactory.class;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prob. not a blocker for this PR, but what if other ResponseProcessor implementations also need custom injection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erm, that's the whole idea of this PR? If somebody wants to inject their
own custom ResponseProcessor then they:

  1. Define their CustomResponseProcessor.
  2. Define their CustomResponseProcessorFactory.
  3. Override this method and return CustomResponseProcessorFactory.class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean if they have non-empty constructors? Then they'd need to make their
constructor injectable so that HK2 can handle it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense

-- We would like to do a little bit of Druid error analysis to extract
some more illuminating error codes out of some of Druid's 500's. The
error callback is controlled by the `ResponseProcessor`.

-- Unfortunately, the `ResponseProcessor` can't be injected directly
because it depends on the `DataApiRequest`, which is built directly in
each request. So instead we wrap the creation of `ResponseProcessor` in
a factory that can be injected.
@archolewa archolewa merged commit ea19531 into master Apr 6, 2018
@archolewa archolewa deleted the inject-response-processor branch April 6, 2018 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants