Skip to content

213 - Allow to send async response using internal HTTP endpoint#215

Merged
mmacai merged 3 commits intomasterfrom
213-internal-response-from
May 21, 2019
Merged

213 - Allow to send async response using internal HTTP endpoint#215
mmacai merged 3 commits intomasterfrom
213-internal-response-from

Conversation

@mmacai
Copy link
Copy Markdown
Collaborator

@mmacai mmacai commented May 16, 2019

Description

Added new internal POST endpoint /v1/responses to ack pending reverse proxy request. Added new response_from option http_internal to await ack from mentioned endpoint.

Closes #213

What to look out for

  • Check docs and swagger
  • Check naming - not sure if http_internal is the best choice, but didn't think about anything better, short and clear enough for everyone
  • Check implementation and integration test (decided to put it alongside existing http scenario)
  • @chadmott verify if following solution fulfils your needs

You can also test it via:

# terminal 1
config="[{\"id\":\"my-service\",\"version_data\":{\"default\":{\"endpoints\":[{\"id\":\"my-endpoint\",\"method\":\"GET\",\"path\":\"\/http\",\"response_from\":\"http_internal\"}]}},\"proxy\":{\"use_env\":true,\"target_url\":\"API_HOST\",\"port\":3000}}]"
# terminal 1
PROXY_CONFIG_FILE="$config" PROXY_HTTP_RESPONSE_TIMEOUT=30000 mix phx.server
# terminal 2
node examples/api-gateway/service.js
# terminal 3
curl "http://localhost:4000/http"
# terminal 4 - copy&paste correlation ID from terminal 2
curl -X POST "http://localhost:4010/v1/responses" -H "accept: application/json" -H "content-type: application/json" -d "{ \"rig\": { \"correlation\": \"g2dkAA1ub25vZGVAbm9ob3N0AAADpgAAAAAA\" }}"

Process

The goal is to improve not only the code in this PR but also our skills! The "rules":

  • The review is considered "done" as soon as all reviewers have added their review, and all their comments have been addressed.
  • For knowledge-sharing reviews, each reviewer should "approve" the PR after studying its content.
  • After the approval, the merge is concluded by the developer.

Have fun!

@mmacai mmacai requested a review from kevinbader May 16, 2019 09:47
@kevinbader kevinbader self-assigned this May 17, 2019
@kevinbader
Copy link
Copy Markdown
Contributor

http_internal => what about http_async?

@mmacai
Copy link
Copy Markdown
Collaborator Author

mmacai commented May 17, 2019

http_internal => what about http_async?

Might be, my idea was to avoid sync/async since it might be confusing for people.

Comment thread apps/rig_api/lib/rig_api/controllers/responses_controller.ex Outdated
Comment thread apps/rig_inbound_gateway/config/config.exs Outdated
Comment thread apps/rig_tests/test/proxy/response_from/http_test.exs Outdated
Comment thread apps/rig_tests/test/proxy/response_from/http_test.exs Outdated
Comment thread docs/rig-ops-guide.md Outdated
@kevinbader
Copy link
Copy Markdown
Contributor

http_internal => what about http_async?

Might be, my idea was to avoid sync/async since it might be confusing for people.

The problem with http_internal is that "internal" refers to how we're used to call RIG's internal API. But I don't think anybody else would relate. At least with async http we would make a statement that it's http, but not the sync response. Not ideal either, I know, but I still it's better than internal, to be honest.

@mmacai mmacai merged commit 4bfec69 into master May 21, 2019
@mmacai mmacai deleted the 213-internal-response-from branch May 21, 2019 12:09
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.

Allow to send async response using HTTP request against internal port

2 participants