Skip to content

Conversation

@fishcakez
Copy link
Member

Adds support for a GenStage process to encapsulate a SQL transaction for use with Flow.

This is WIP.

  • Add examples
  • Improve test coverage
  • Add wrapper for Postgrex.Stage.copy/4
  • Merge related PRs

Related PRs:
elixir-ecto/db_connection#82
elixir-ecto/postgrex#312

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)

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.

{:suspend, {0, [v | acc]}}
end
defp stream_reduce(v, {n, acc}) do
{:cont, {n-1, [v | acc]}}

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

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

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

@josevalim josevalim force-pushed the master branch 8 times, most recently from 8527ce2 to 7aa5c62 Compare April 23, 2017 09:39

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: fiftth

@fishcakez
Copy link
Member Author

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 all/1, and the second like insert_all/2:

MyRepo.start_producer(Post)
MyRepo.start_consumer(Post)

Also lower level versions in Ecto.Adapters.SQL. However neither Postgrex.CopyConsumer nor checkout_begin etc

@sourcelevel-bot
Copy link

Ebert has finished reviewing this Pull Request and has found:

  • 6 possible new issues (including those that may have been commented here).
  • 427 fixed issues! 🎉

But beware that this branch is 46 commits behind the elixir-ecto:master branch, and a review of an up to date branch would produce more accurate results.

You can see more details about this review at https://ebertapp.io/github/elixir-ecto/ecto/pulls/2028.

@josevalim
Copy link
Member

I will go ahead and close this since we have no plans to pick this up.

@josevalim josevalim closed this Aug 22, 2018
@josevalim josevalim deleted the jf-sql-stage branch October 22, 2018 12:30
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