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

A single flow for all outgoing HTTP requests #729

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

tareksha
Copy link
Contributor

@tareksha tareksha commented Aug 2, 2016

phase 1 - builder, runner, all json requests

An injected interface, HttpRequestFactory, allows managing all outgoing
HTTP requests. HttpJsonRequest factory should use it internally. The
defult DefaultHttpJsonRequest as reusable as it accepts the general HTTP
factory in its constructor. Extensions can replace HttpJsonRequestFactory
and provide DefaultHttpJsonRequest as-is, given a different impl.

Signed-off-by: Tareq Sharafy tareq.sha@gmail.com
Change-Id: I2f334b7bb133b3f136d2b8e5b18301602f427355

@tareksha
Copy link
Contributor Author

tareksha commented Aug 2, 2016

@skabashnyuk @evoevodin please review

@@ -90,6 +92,10 @@ public boolean isValid(DeploymentSources deployment) {
private ScheduledExecutorService cleanScheduler;
private java.io.File deployDirectory;

@Inject
private DownloadPlugin theDownloadPlugin;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why we still need old field, looks like it is unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@garagatyi the old field is final protected, not private. i saw it too risky to just remove it or hide non-incrementally.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't notice that, thanks.

@tareksha
Copy link
Contributor Author

@garagatyi the change now uses the same builder pattern. please review

@tareksha tareksha force-pushed the single_http_flow branch 9 times, most recently from 10d17fa to f385a76 Compare August 24, 2016 16:59
@skabashnyuk
Copy link
Contributor

@tareqhs Quick response is -1 to make HttpJsonRequest something not related to json. We understand that you want to make some tooling to make general request but making it in HttpJsonRequest is not that we want to achieve. I hope @garagatyi @evoevodin can add more to this statement.

@voievodin
Copy link
Contributor

Hi @tareqhs.
Generally speaking HttpJsonRequest was designed to work with json only, there are several reasons for that

  • 90% requests are requests between our API services where json is a main format, so it fits almost all the needs
  • when the tool is json specialized we can add useful methods related to DTO processing, which is also json based, so the tool becomes even more convenient and usable.

The idea of you changes is clear for me and makes total sense, but the implementation strategy should be different, as HttpJsonRequest becomes not really Json and the client of the class may be confused as the class contains general and json request logic mixed.

As for me the best solution here is to create general class like HttpRequest with all the general methods for requesting stuff through http and then change the current HttpJsonRequest implementation to use HttpRequest in this way the logic is clearly separated between components.

@tareksha
Copy link
Contributor Author

tareksha commented Aug 27, 2016

hi @evoevodin @skabashnyuk ,

Well, that was the original approach in the PR but I tried to minimize code changes. The main issue is not whether to extend HttpJsonRequest itself or not, but rather the factory HttpJsonRequestFactory. I'm seeking a solution that doesn't require injecting a new factory everywhere yet again, which conceptually is a superset of HttpJsonRequestFactory.

This is my suggestion : HttpJsonRequestFactory extends a general HttpRequestFactory that has general request methods, so that the existing injections stay identical except for receiving the additional HTTP APIs that are in turn used instead of HttpURLConnection where needed.

Agree?

phase 1 - builder, runner, all json requests

A new builder inteface HttpRequest, sharing features with the existing
HttpJsonRequest, allows building general requests and consuming responses
through HttpResponse. A single HTTP flow is achieving by sharing a single
concrete HTTP request execution method.

Signed-off-by: Tareq Sharafy <tareq.sha@gmail.com>
Change-Id: I2f334b7bb133b3f136d2b8e5b18301602f427355
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants