Skip to content

Conversation

@fishcakez
Copy link
Member

This is WIP. Includes a common real world example of a :consumer stage.

@@ -0,0 +1,93 @@
defmodule Postgrex.Stage do

Choose a reason for hiding this comment

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

Modules should have a @moduledoc tag.

end

defp copy_data(conn, data, %Postgrex.Copy{ref: ref} = copy, opts) do
try do

Choose a reason for hiding this comment

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

Prefer using an implicit try rather than explicit try.

Copy link
Member Author

Choose a reason for hiding this comment

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

no thank you

Copy link
Member

Choose a reason for hiding this comment

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

Don't worry @ebert[bot], I got your back. :P

end

defp suspend(s, status, query, cursor, rows, buffer) do
defp suspend(s, status, query, _cursor, rows, buffer) do

Choose a reason for hiding this comment

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

Function takes too many parameters (arity is 6, max is 5).

test "produce COPY TO STDOUT", context do
query = "COPY (VALUES (1, 2), (3, 4)) TO STDOUT"
parent = self()
opts = [stream_mapper: fn(_, %{rows: rows}) -> send(parent, rows) ; rows end]

Choose a reason for hiding this comment

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

Don't use ; to separate statements and expressions

test "produce query in chunks", context do
query = prepare("", "SELECT * FROM generate_series(1, 3)")
parent = self()
opts = [stream_mapper: fn(_, %{rows: rows}) -> send(parent, rows) ; rows end]

Choose a reason for hiding this comment

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

Don't use ; to separate statements and expressions

defmodule StageTest do
use ExUnit.Case, async: true
import Postgrex.TestHelper
alias Postgrex.{CopyConsumer, Producer}

Choose a reason for hiding this comment

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

Most of the time you are using the multiple single line alias/require/import/use directives but here you are using the multi-alias/require/import/use syntax

@sourcelevel-bot
Copy link

Ebert has finished reviewing this Pull Request and has found:

  • 178 possible new issues (including those that may have been commented here).

But beware that this branch is 1 commit 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/postgrex/pulls/312.

## Examples
{:ok, pid} = Postgrex.Producer.start_link(pool, "SELECT * FROM posts, [])
Copy link
Member

Choose a reason for hiding this comment

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

Missing closing quotes.

{:ok, pid} = Postgrex.Producer.start_link(pool, "SELECT * FROM posts, [])
[{pid, [cancel: :transient]}]
|> GenStage.stream()
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this example, let's make an imaginary consumer subscribe to the producer. That's because this use case is better done with streams.

@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

## Examples
{:ok, pid} = Postgrex.Producer.start_link(pool, "SELECT * FROM posts, [])

Choose a reason for hiding this comment

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

Missing the closing ".

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for taking a look, we aren't going to go ahead with this approach. Please see #321.

@fishcakez fishcakez closed this Aug 24, 2017
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