AppBlockList.Queue (AppBlockList v1.0.0)

Copy Markdown View Source

A GenServer that owns one client and sends lookups one at a time.

Every caller in your application goes through the same process, so the service sees an ordered stream of requests with at least :interval milliseconds between them, no matter how many LiveViews, Oban jobs or Broadway stages ask at once. Answers (including not-found answers) are cached for :ttl milliseconds.

children = [
  {AppBlockList.Queue, interval: 150, ttl: :timer.hours(24)}
]

{:ok, app} = AppBlockList.Queue.lookup("com.zhiliaoapp.musically")

Options: :name (default AppBlockList.Queue), :interval (ms, default 100), :ttl (ms, default 24 hours), :client (an AppBlockList.Client; default AppBlockList.Client.new() at start), any other option is passed to AppBlockList.Client.new/1.

Summary

Functions

Returns a specification to start this module under a supervisor.

Drops every cached answer.

Looks up an ID through the queue. Same return values as AppBlockList.Client.lookup/2.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear_cache(server \\ __MODULE__)

Drops every cached answer.

lookup(server \\ __MODULE__, id, timeout \\ 60000)

@spec lookup(GenServer.server(), String.t(), timeout()) ::
  {:ok, AppBlockList.App.t()} | {:error, AppBlockList.Error.t()}

Looks up an ID through the queue. Same return values as AppBlockList.Client.lookup/2.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()