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

Use channels more consistently for endpoint sequences #675

Closed
johakoch opened this issue Jan 27, 2023 · 0 comments · Fixed by #684
Closed

Use channels more consistently for endpoint sequences #675

johakoch opened this issue Jan 27, 2023 · 0 comments · Fixed by #684
Assignees
Labels
refactoring E.g. optimizing an already existing feature
Milestone

Comments

@johakoch
Copy link
Collaborator

johakoch commented Jan 27, 2023

The handling of endpoint sequences is currently quite complicated. And sometimes the test TestEndpoint_Sequence/complex_request/proxy_sequences fails.

We could create producers with output and, if needed, input channels that connect the producers and by which producers pass their "product" to other producers.

endpoint "/**" {
  request "a" {
    url = "..."
  }

  request "b" {
    url = "..."
    json_body = backend_responses.a.json_body.foo
  }

  request "c" {
    url = "..."
    json_body = backend_responses.a.json_body.bar
  }

  request "d" {
    url = "..."
    json_body = {
      b = backend_responses.b.json_body
      c = backend_responses.c.json_body
    }
  }

  response {
    json_body = {
      d = backend_responses.d.json_body
    }
  }
}

could lead to

        +----------+
        | pReq "a" |
        +----------+
         |        |
   c0 +--+        +--+ c1
      |              |
      v              v
+----------+    +----------+
| pReq "b" |    | pReq "c" |
+----------+    +----------+
      |              |
   c2 +--+        +--+ c3
         |        |
         v        v
        +----------+
        | pReq "d" |
        +----------+
             |
          c4 |
             v

with e.g. pReq "a" having no input, but two output channels, and pReq "d" having two input and one output channel.

Then call each producer's Produce() in its own go routine. The producers without input channels will produce first, while the others wait for all their input channels to be filled before producing.

See simplified demo at https://go.dev/play/p/JzxaWhxa7Pj and a more elaborate one at https://go.dev/play/p/Tt1JllFoG4v

@johakoch johakoch added the refactoring E.g. optimizing an already existing feature label Jan 27, 2023
@johakoch johakoch self-assigned this Jan 30, 2023
@johakoch johakoch linked a pull request Jan 31, 2023 that will close this issue
@johakoch johakoch added this to the 1.13 milestone Feb 16, 2023
@johakoch johakoch assigned malud and unassigned johakoch Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring E.g. optimizing an already existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants