Skip to content

Commit

Permalink
Adjust formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyowensboggs committed Feb 23, 2024
1 parent b1f1ddf commit 71dbd8e
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 22 deletions.
4 changes: 1 addition & 3 deletions lib/faktory_worker/batch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ defmodule FaktoryWorker.Batch do
@spec new!(Keyword.t()) :: {:ok, bid()} | {:error, any()}
def new!(opts \\ []) do
if Sandbox.active?() do
{:ok, Sandbox.batch_id}
{:ok, Sandbox.batch_id()}
else
success = Keyword.get(opts, :on_success)
complete = Keyword.get(opts, :on_complete)
Expand All @@ -118,7 +118,6 @@ defmodule FaktoryWorker.Batch do

opts = Keyword.take(opts, [:faktory_name, :timeout])
FaktoryWorker.send_command({:batch_new, payload}, opts)

end
end

Expand Down Expand Up @@ -163,7 +162,6 @@ defmodule FaktoryWorker.Batch do
else
FaktoryWorker.send_command({:batch_status, bid}, opts)
end

end

defp maybe_put_description(payload, nil), do: payload
Expand Down
4 changes: 2 additions & 2 deletions lib/faktory_worker/connection_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defmodule FaktoryWorker.ConnectionManager do
state = %{state | conn: nil}

if allow_retry,
do: send_command(%{state | conn: nil}, command, false),
do: send_command(state, command, false),
else: {error, state}

# Handle errors from Faktory that should not be tried again
Expand Down Expand Up @@ -87,6 +87,6 @@ defmodule FaktoryWorker.ConnectionManager do
defp close_connection(%{conn: nil}), do: :ok

defp log_error(reason, {_, %{jid: jid}}) do
Logger.warn("[#{jid}] #{reason}")
Logger.warning("[#{jid}] #{reason}")
end
end
17 changes: 9 additions & 8 deletions lib/faktory_worker/sandbox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ defmodule FaktoryWorker.Sandbox do

def batch_id, do: "sandbox-batch-id"

def batch_status, do: %{
"bid" => batch_id(),
"total" => 10,
"pending" => 14,
"failed" => 3,
"created_at" => "2019-11-18T13:48:25Z",
"description" => "This is a sandbox status"
}
def batch_status,
do: %{
"bid" => batch_id(),
"total" => 10,
"pending" => 14,
"failed" => 3,
"created_at" => "2019-11-18T13:48:25Z",
"description" => "This is a sandbox status"
}
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ defmodule FaktoryWorker.Connection.ConnectionIntegrationTest do

alias FaktoryWorker.Connection

@passworded_connection_opts Application.get_env(:faktory_worker, :passworded_server)
@tls_connection_opts Application.get_env(:faktory_worker, :tls_server)
@passworded_connection_opts Application.compile_env(:faktory_worker, :passworded_server)
@tls_connection_opts Application.compile_env(:faktory_worker, :tls_server)

describe "open/1" do
test "should return a connection to faktory" do
Expand Down
4 changes: 2 additions & 2 deletions test/faktory_worker/connection/socket/ssl_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule FaktoryWorker.Connection.Socket.SslTest do
alias FaktoryWorker.Connection
alias FaktoryWorker.Socket.Ssl

@tls_host Application.get_env(:faktory_worker, :tls_server)[:host]
@tls_port Application.get_env(:faktory_worker, :tls_server)[:port]
@tls_host Application.compile_env(:faktory_worker, :tls_server)[:host]
@tls_port Application.compile_env(:faktory_worker, :tls_server)[:port]

describe "connect/3" do
test "should open a ssl socket to faktory" do
Expand Down
2 changes: 2 additions & 0 deletions test/faktory_worker/connection_manager_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ defmodule FaktoryWorker.ConnectionManagerTest do
{:ok, "+OK\r\n"}
end)

expect(FaktoryWorker.SocketMock, :close, fn _ -> :ok end)

opts = [socket_handler: FaktoryWorker.SocketMock]

state = %ConnectionManager{
Expand Down
6 changes: 3 additions & 3 deletions test/faktory_worker/error_formatter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ defmodule FaktoryWorker.ErrorFormatterTest do

describe "format_error/2" do
@stacktrace [
{TestApp.Worker, :raise_error, 1, [file: 'lib/worker.ex', line: 50]},
{TestApp.Worker, :do_work, 1, [file: 'lib/worker.ex', line: 37]},
{TestApp.Worker, :perform, 1, [file: 'lib/worker.ex', line: 9]}
{TestApp.Worker, :raise_error, 1, [file: ~c"lib/worker.ex", line: 50]},
{TestApp.Worker, :do_work, 1, [file: ~c"lib/worker.ex", line: 37]},
{TestApp.Worker, :perform, 1, [file: ~c"lib/worker.ex", line: 9]}
]

@formatted_stacktrace [
Expand Down
1 change: 0 additions & 1 deletion test/faktory_worker/job/job_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,4 @@ defmodule FaktoryWorker.Job.JobTest do
assert error == "The field 'queue' has an invalid value '123'"
end
end

end
2 changes: 2 additions & 0 deletions test/faktory_worker/worker/heartbeat_server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ defmodule FaktoryWorker.Worker.HeartbeatServerTest do
{:error, :econnrefused}
end)

expect(FaktoryWorker.SocketMock, :close, fn _ -> :ok end)

opts = [socket_handler: FaktoryWorker.SocketMock, is_worker: true, process_wid: process_wid]

state = %{
Expand Down
4 changes: 3 additions & 1 deletion test/faktory_worker/worker/server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule FaktoryWorker.Worker.ServerTest do
id: :test_worker_1,
start:
{FaktoryWorker.Worker.Server, :start_link,
[[name: :test_worker_1, connection: [port: 7000]]]},
[[name: :test_worker_1, connection: [port: 7000]]]},
type: :worker
}
end
Expand Down Expand Up @@ -247,6 +247,7 @@ defmodule FaktoryWorker.Worker.ServerTest do
state
|> Map.put(:job_id, job_id)
|> Map.put(:job_ref, %{ref: job_ref})
|> Map.put(:job_start, System.monotonic_time(:millisecond))
end)

Process.send(pid, {job_ref, :ok}, [])
Expand Down Expand Up @@ -289,6 +290,7 @@ defmodule FaktoryWorker.Worker.ServerTest do

:sys.replace_state(pid, fn state ->
state
|> Map.put(:job_start, System.monotonic_time(:millisecond))
|> Map.put(:job_id, job_id)
|> Map.put(:job, %{"jid" => job_id})
end)
Expand Down

0 comments on commit 71dbd8e

Please sign in to comment.