Web Resolver Behaviour
A new Oban.Web.Resolver
behaviour module allows users to resolve the current
user when loading the dashboard, apply per-user access controls and set per-user
refresh rates.
defmodule MyApp.Resolver do
@behaviour Oban.Web.Resolver
@impl true
def resolve_user(conn) do
conn.private.current_user
end
@impl true
def resolve_access(user) do
if user.admin? do
[cancel_jobs: true, delete_jobs: true, retry_jobs: true]
else
:read_only
end
end
@impl true
def resolve_refresh(_user), do: 1
end
Pass your Resolver
callback to oban_dashboard
in your router:
scope "/" do
pipe_through :browser
oban_dashboard "/oban", resolver: MyApp.Resolver
end
Viola, your dashboard now has per-user access controls! Now only admins can
cancel, retry or delete jobs while other users can still monitor running jobs
and check stats.
Telemetry Integration
The Oban.Web.Telemetry
module adds events for instrumentation, logging, error
reporting and activity auditing.
Action events are emitted whenever a user performs a write operation with the
dashboard, e.g. pausing a queue, cancelling a job, etc. Web now ships with a log
handler that you can attach to get full dashboard audit logging. Add this call
at application start:
Oban.Web.Telemetry.attach_default_logger(:info)
It will output structured JSON logs matching the format that Oban uses,
including the user that performed the action:
{
"action":"cancel_jobs",
"duration":2544,
"event":"action:stop",
"job_ids":[290950],
"oban_name":"Oban",
"source":"oban_web",
"user":1818
}
Enhancements
-
Remove a hard dependency on oban_pro
. If you rely on any Pro plugins be sure
to specify an oban_pro
dependency in your mix.exs
.
-
Remove erroneous batch “Delete” action from states where it shouldn’t apply,
e.g. executing
.
-
Require confirmation before deleting jobs. Deleting is permanent and
irreversible, unlike cancelling or other possible actions.
-
Optimize the query that calculates queue and state counts in the sidebar. With
millions of jobs the query could take longer than the refresh rate, leading to
problems.