• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

akira / exq / 16bf7540e38e434e6ed4fadc1f40894960dd12db-PR-500

07 Aug 2025 11:50AM UTC coverage: 90.805% (-1.6%) from 92.382%
16bf7540e38e434e6ed4fadc1f40894960dd12db-PR-500

Pull #500

github

ananthakumaran
Run coveralls on one build only
Pull Request #500: Add ability to snooze job

15 of 15 new or added lines in 2 files covered. (100.0%)

18 existing lines in 13 files now uncovered.

1195 of 1316 relevant lines covered (90.81%)

706.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.94
/lib/exq.ex
1
defmodule Exq do
2
  require Logger
3
  use Application
4

5
  import Exq.Support.Opts, only: [top_supervisor: 1]
6
  alias Exq.Worker.Metadata
7
  alias Exq.Support.Config
8

9
  # Mixin Enqueue API
10
  use Exq.Enqueuer.EnqueueApi
11

12
  def child_spec(exq_options \\ []) do
13
    %{
×
14
      id: __MODULE__,
15
      type: :supervisor,
16
      start: {__MODULE__, :start_link, [exq_options]}
17
    }
18
  end
19

20
  # See http://elixir-lang.org/docs/stable/elixir/Application.html
21
  # for more information on OTP Applications
22
  def start(_type, _args) do
23
    if Config.get(:start_on_application) do
×
24
      start_link()
×
25
    else
26
      # Don't start Exq
27
      Supervisor.start_link([], strategy: :one_for_one)
×
28
    end
29
  end
30

31
  # Exq methods
32
  def start_link(opts \\ []) do
33
    children = Exq.Support.Mode.children(opts)
127✔
34

35
    Supervisor.start_link(children,
127✔
36
      name: top_supervisor(opts[:name]),
37
      strategy: :one_for_one,
38
      max_restarts: 20,
39
      max_seconds: 5
40
    )
41
  end
42

UNCOV
43
  def stop(nil), do: :ok
×
44
  def stop(pid) when is_pid(pid), do: Process.exit(pid, :shutdown)
×
45

46
  def stop(name) do
47
    name
48
    |> whereis
49
    |> stop
×
50
  end
51

52
  def whereis(name) do
53
    name
54
    |> top_supervisor
55
    |> Process.whereis()
×
56
  end
57

58
  @doc """
59
  List all subscriptions(active queues)
60
    * `pid` - PID for Exq Manager or Enqueuer to handle this
61
  """
62
  def subscriptions(pid) do
63
    GenServer.call(pid, :subscriptions)
4✔
64
  end
65

66
  @doc """
67
  Subscribe to a queue - ie. listen to queue for jobs
68
    * `pid` - PID for Exq Manager or Enqueuer to handle this
69
    * `queue` - Name of queue
70
    * `concurrency` - Optional argument specifying max concurrency for queue
71
  """
72
  def subscribe(pid, queue) do
73
    GenServer.call(pid, {:subscribe, queue})
1✔
74
  end
75

76
  def subscribe(pid, queue, concurrency) do
77
    GenServer.call(pid, {:subscribe, queue, concurrency})
1✔
78
  end
79

80
  @doc """
81
  Unsubscribe from a queue - ie. stop listening to queue for jobs
82
    * `pid` - PID for Exq Manager or Enqueuer to handle this
83
    * `queue` - Name of queue
84
  """
85
  def unsubscribe(pid, queue) do
86
    GenServer.call(pid, {:unsubscribe, queue})
2✔
87
  end
88

89
  @doc """
90
  Unsubscribe from all queues - ie. stop listening for jobs
91
    * `pid` - PID for Exq Manager or Enqueuer to handle this
92
  """
93
  def unsubscribe_all(pid) do
94
    GenServer.call(pid, :unsubscribe_all)
122✔
95
  end
96

97
  @doc """
98
  Get the job metadata
99
    * `name` - registered name of Exq. Only necessary if the custom
100
      name option is used when starting Exq. Defaults to Exq
101
    * `pid` - pid of the worker. Defaults to self().
102
  """
103
  def worker_job(name \\ nil, pid \\ self()) do
104
    metadata = Metadata.server_name(name)
31✔
105
    Metadata.lookup(metadata, pid)
31✔
106
  end
107
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc