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

Allow an asynchronous service to respond immediately #300

Closed
kevinbader opened this issue May 4, 2020 · 0 comments · Fixed by #318
Closed

Allow an asynchronous service to respond immediately #300

kevinbader opened this issue May 4, 2020 · 0 comments · Fixed by #318
Assignees
Milestone

Comments

@kevinbader
Copy link
Contributor

kevinbader commented May 4, 2020

When in the reverse-proxy configuration a route has target http and the response_from option is present, the synchronous response is dropped.

+----------+                    +-------+                       +----------------+
|          +------------------->+       +---------------------->+                |
|  Client  |                    |  RIG  |                       |  Microservice  |
|          +<-------------------+       |  X <------------------+                |
+----------+                    +---+---+                       +-------+--------+
               async response       ^      response                     |
                                    |      is dropped                   |
                                    |                                   |
                                    |                                   +
                                    |
                                    |                               later...
                                    |
                                    |                                   +
                                    |                                   |
                                    |         async response            |
                                    |                                   |
                                    +-----------------------------------+

The idea is to make this more flexible:

  • Simply return the response as if response_from was not set
  • If the response's status code is 202 Accepted, ignore the response and wait for the result

This way, a microservice can return a cached response or an error immediately:

+----------+                    +-------+                       +----------------+
|          +------------------->+       +---------------------->+                |
|  Client  |                    |  RIG  |                       |  Microservice  |
|          +<-------------------+       +<----------------------+                |
+----------+                    +-------+                       +----------------+
                                               bad request!

We could add this as an option to the current configuration but I think that would make an already complex-looking configuration even weirder. So I propose this as a breaking change to be included in the upcoming 3.0 release.

Implementation notes

Take a look at lib/rig_inbound_gateway/api_proxy/handler/http.ex

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 a pull request may close this issue.

2 participants