MishkaCmsCore.Runtime.ShareCardQueue (Mishka CMS Core v0.0.1)

Copy Markdown View Source

The Oban queue share cards are drawn on, :share_cards, and how many are drawn at once: the share_cards.workers setting (Settings → SEO → Share cards, master only), from 0 to 4, 1 by default. 0 pauses the queue: the cards wait in it, and are drawn once it is set above 0 again.

Every job that draws a share card, or looks at one, runs on it: MishkaCmsCore.Runtime.ShareCard and MishkaCmsCore.Runtime.Workers.ShareCardRefreshWorker, and an extension's or a site's own drawing worker the same way, use Oban.Worker, queue: :share_cards. So a redraw of every card of a site — after its address changes — draws one card at a time, and never holds up a stylesheet build on :assets.

A host lists the queue in its Oban queues, paused, and the boot starts it:

config :my_app, Oban,
  queues: [default: 5, assets: 2, share_cards: [limit: 1, paused: true]]

When the setting is applied

Registered in MishkaCmsCore.Application.

Summary

Functions

Applies the stored setting to this node's queue (scale/2 with local_only: true), and says so in the log when the queue is not in the app's Oban queues. Takes scale/2's :oban.

Returns a specification to start this module under a supervisor.

Callback implementation for MishkaInstaller.Event.Hook.enable/0.

Callback implementation for MishkaInstaller.Event.Hook.get/0.

Optional. See MishkaInstaller.Event.Hook.health_check/0. Override to report health.

The setting that says how many share cards are drawn at once.

The queue every share-card job runs on.

Callback implementation for MishkaInstaller.Event.Hook.register/0.

Callback implementation for MishkaInstaller.Event.Hook.restart/0.

Draws workers share cards at once: the queue scaled to that many and resumed, or paused for 0.

The setting's definition, on the SEO tab of the settings page.

Callback implementation for MishkaInstaller.Event.Hook.start/0.

Callback implementation for MishkaInstaller.Event.Hook.stop/0.

How many share cards are drawn at once: the stored setting, within 0..4.

Types

error_return()

@type error_return() ::
  {:error, [%{action: atom(), field: atom(), message: String.t()}]}

okey_return()

@type okey_return() :: {:ok, struct() | map() | module() | [any()]}

Functions

boot(opts \\ [])

@spec boot(keyword()) :: :ok | {:error, term()}

Applies the stored setting to this node's queue (scale/2 with local_only: true), and says so in the log when the queue is not in the app's Oban queues. Takes scale/2's :oban.

A node that does not serve the site (MishkaCmsCore.Runtime.Handlers.BootHandler.serving?/0) sends nothing and leaves its queue as it is: the cards it would draw are the serving node's, and even a local_only signal reaches every node of the same Oban name.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

config()

@spec config() :: keyword()

config(key)

@spec config(atom()) :: any()

enable()

@spec enable() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.enable/0.

get()

@spec get() :: keyword()

Callback implementation for MishkaInstaller.Event.Hook.get/0.

health_check()

@spec health_check() :: :ok | {:degraded, term()} | {:error, term()}

Optional. See MishkaInstaller.Event.Hook.health_check/0. Override to report health.

key()

@spec key() :: String.t()

The setting that says how many share cards are drawn at once.

on_dependency_error(error)

@spec on_dependency_error(term()) :: term()

Optional. See MishkaInstaller.Event.Hook.on_dependency_error/1. Override to react.

queue()

@spec queue() :: atom()

The queue every share-card job runs on.

register()

@spec register() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.register/0.

restart()

@spec restart() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.restart/0.

scale(workers, opts \\ [])

@spec scale(integer(), keyword()) :: :ok | {:error, term()}

Draws workers share cards at once: the queue scaled to that many and resumed, or paused for 0.

Options:

  • :oban — the Oban instance, Oban by default
  • :local_only — true for this node's queue alone; every node's by default

{:error, :not_running} when that Oban instance is not running, and {:error, :no_queue} for local_only: true when this node runs no :share_cards queue.

settings()

@spec settings() :: [MishkaCmsCore.Settings.definition()]

The setting's definition, on the SEO tab of the settings page.

start()

@spec start() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.start/0.

start_link(args \\ [])

stop()

@spec stop() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.stop/0.

unregister()

@spec unregister() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.unregister/0.

workers()

@spec workers() :: 0..4

How many share cards are drawn at once: the stored setting, within 0..4.