-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Introduce Ecto.Adapters.SQL.Stage #2028
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
Conversation
lib/ecto/adapters/sql/stage.ex
Outdated
| GenServer.on_start when acc: var | ||
| def producer(repo, start, handle_demand, stop, opts \\ []) do | ||
| fun = &DBConnection.Stage.producer/5 | ||
| Ecto.Adapters.SQL.stage(fun, repo, start, handle_demand, stop, opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be no trailing white-space at the end of a line.
lib/ecto/adapters/sql/stage.ex
Outdated
| {:suspend, {0, [v | acc]}} | ||
| end | ||
| defp stream_reduce(v, {n, acc}) do | ||
| {:cont, {n-1, [v | acc]}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are spaces around operators most of the time, but not here.
| assert [p1, p2, p3] = stage |> to_list() |> sort_by_id() | ||
|
|
||
| assert [%Comment{id: ^cid1}, %Comment{id: ^cid2}] = p1.comments |> sort_by_id | ||
| assert [%Comment{id: ^cid3}, %Comment{id: ^cid4}] = p2.comments |> sort_by_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a function call when a pipeline is only one function long
|
|
||
| assert [p1, p2, p3] = stage |> to_list() |> sort_by_id() | ||
|
|
||
| assert [%Comment{id: ^cid1}, %Comment{id: ^cid2}] = p1.comments |> sort_by_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a function call when a pipeline is only one function long
8527ce2 to
7aa5c62
Compare
lib/ecto/adapters/sql/stage.ex
Outdated
|
|
||
| The first argument is the repo, the second argument is the start function, | ||
| the third argument is the handle demand function, the fourth argument is the | ||
| stop function and the optional fiftth argument are the options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: fiftth
|
Changed this up quite a bit, so we can now have what I assume will be far the two most common cases in easy reach, the first acting like MyRepo.start_producer(Post)
MyRepo.start_consumer(Post)Also lower level versions in |
|
Ebert has finished reviewing this Pull Request and has found:
But beware that this branch is 46 commits behind the You can see more details about this review at https://ebertapp.io/github/elixir-ecto/ecto/pulls/2028. |
|
I will go ahead and close this since we have no plans to pick this up. |
Adds support for a
GenStageprocess to encapsulate a SQL transaction for use withFlow.This is WIP.
Related PRs:
elixir-ecto/db_connection#82
elixir-ecto/postgrex#312