Skip to content

Commit

Permalink
adds proper error return for mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
jscott22 committed Feb 7, 2019
1 parent 89aa606 commit 035740a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
6 changes: 5 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ version: "3"
services:
bigtable-emulator:
image: shopify/bigtable-emulator
command: ["-cf", "dev.test.cf1,dev.test.cf2,dev.test.otherFamily"]
command:
[
"-cf",
"dev.test.cf1,dev.test.cf2,dev.test.otherFamily,dev.dev.cf1,dev.dev.cf2,dev.dev.otherFamily",
]
ports:
- "9035:9035"
expose:
Expand Down
17 changes: 12 additions & 5 deletions lib/operations/mutate_row.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,22 @@ defmodule Bigtable.MutateRow do

connection = Connection.get_connection()

{:ok, stream, _} =
result =
connection
|> Bigtable.Stub.mutate_row(request, metadata)

result =
stream
|> Utils.process_stream()
case result do
{:ok, stream, _} ->
stream
|> Utils.process_stream()
|> List.first()

{:error, error} when is_map(error) ->
{:error, Map.get(error, :message, "unknown error")}

{:ok, result}
_ ->
{:error, "unknown error"}
end
end

@spec mutate(V2.MutateRowsRequest.Entry.t()) :: V2.MutateRowResponse.t()
Expand Down
17 changes: 12 additions & 5 deletions lib/operations/mutate_rows.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,22 @@ defmodule Bigtable.MutateRows do

metadata = Connection.get_metadata()

{:ok, stream, _} =
result =
connection
|> Bigtable.Stub.mutate_rows(request, metadata)

result =
stream
|> Utils.process_stream()
case result do
{:ok, stream, _} ->
stream
|> Utils.process_stream()
|> List.first()

{:error, error} when is_map(error) ->
{:error, Map.get(error, :message, "unknown error")}

{:ok, result}
_ ->
{:error, "unknown error"}
end
end

@spec mutate([Google.Bigtable.V2.MutateRowsRequest.Entry.t()]) :: {:ok, [any()]}
Expand Down
6 changes: 6 additions & 0 deletions test/row_filter/row_filter_integration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ defmodule RowFilterIntegration do
|> Mutations.set_cell("cf2", "column1", "value3", 4000)
|> MutateRow.build()
|> MutateRow.mutate()

:ok
end

defp seed_range(row_key) do
Expand All @@ -475,6 +477,8 @@ defmodule RowFilterIntegration do
|> Mutations.set_cell("cf1", "column5", "value5")
|> MutateRow.build()
|> MutateRow.mutate()

:ok
end

defp seed_values(context) do
Expand All @@ -484,6 +488,8 @@ defmodule RowFilterIntegration do
|> Mutations.set_cell("cf1", "column", "value")
|> MutateRow.build()
|> MutateRow.mutate()

:ok
end)
end

Expand Down

0 comments on commit 035740a

Please sign in to comment.