Skip to content

Commit aa608e7

Browse files
committed
fix timeout option when calling get_more
1 parent 86b64b9 commit aa608e7

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/mongo.ex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,19 +1524,19 @@ defmodule Mongo do
15241524

15251525
def exec_hello(conn, opts) do
15261526
with {:ok, _cmd, response} <- DBConnection.execute(conn, %Query{action: {:exec_hello, []}}, [], opts) do
1527-
check_for_error(response, [hello: 1], opts)
1527+
check_for_error(response, :exec_hello, opts)
15281528
end
15291529
end
15301530

15311531
def exec_hello(conn, cmd, opts) do
15321532
with {:ok, _cmd, response} <- DBConnection.execute(conn, %Query{action: {:exec_hello, cmd}}, [], opts) do
1533-
check_for_error(response, cmd, opts)
1533+
check_for_error(response, :exec_hello, opts)
15341534
end
15351535
end
15361536

15371537
def exec_more_to_come(conn, opts) do
15381538
with {:ok, _cmd, response} <- DBConnection.execute(conn, %Query{action: :more_to_come}, [], opts) do
1539-
check_for_error(response, [:more_to_come], opts)
1539+
check_for_error(response, :more_to_come, opts)
15401540
end
15411541
end
15421542

@@ -1747,12 +1747,16 @@ defmodule Mongo do
17471747
do: raise(ArgumentError, "expected list of documents, got: #{inspect(other)}")
17481748

17491749
## support for logging like Ecto
1750-
defp do_log([:more_to_come], _duration, _opts) do
1750+
defp do_log(:more_to_come, _duration, _opts) do
1751+
:ok
1752+
end
1753+
1754+
defp do_log(:exec_hello, _duration, _opts) do
17511755
:ok
17521756
end
17531757

17541758
defp do_log(cmd, duration, opts) do
1755-
case Keyword.has_key?(cmd, :isMaster) || Keyword.has_key?(cmd, :more_to_come) || Keyword.has_key?(cmd, :hello) do
1759+
case Keyword.has_key?(cmd, :isMaster) do
17561760
true ->
17571761
:ok
17581762

lib/mongo/streaming_hello_monitor.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ defmodule Mongo.StreamingHelloMonitor do
116116
defp get_server_description(%{connection_pid: conn_pid, address: address, topology_version: topology_version, max_await_time_ms: max_await_time_ms, opts: opts} = state) do
117117
Mongo.Events.notify(%ServerHeartbeatStartedEvent{connection_pid: conn_pid})
118118

119+
opts = Keyword.merge(opts, timeout: max_await_time_ms * 2)
120+
119121
{duration, result} =
120122
case state do
121123
%{more_to_come: true} ->

0 commit comments

Comments
 (0)