MingaEditor.EffectScheduler.Engine (Minga v0.1.0)

Copy Markdown View Source

Lifecycle, admission-policy, and worker coordination for EffectScheduler.

Summary

Functions

Returns whether a handler has running, queued, or pending work.

Returns whether any active request advertises a semantic activity.

Returns whether a source has running, queued, or pending work.

Returns whether an exact request still holds scheduler admission.

Attaches the scheduler's single owner.

Cancels an admitted request.

Cancels the admitted request correlated with a semantic operation.

Cancels and terminalizes all work for one semantic resource.

Cancels and terminalizes all work attributed to a contribution source.

Atomically claims a still-pending candidate without releasing its resource.

Finalizes a domain-applied candidate, if it is still pending.

Finalizes a candidate and admits its follow-up as one scheduler transition.

Processes an owner or worker DOWN message.

Admits a request according to its resource policy.

Stops all work and terminalizes every admitted request.

Returns bounded scheduler statistics.

Processes a successful worker reply.

Processes a scheduler-owned request timeout.

Types

admission()

@type admission() ::
  {:ok, MingaEditor.Effect.Request.id(), :running | :queued}
  | {:error, admission_error()}

admission_error()

@type admission_error() ::
  :already_admitted
  | :owner_unavailable
  | :policy_mismatch
  | :queue_full
  | :scheduler_full

claim()

@type claim() :: :ok | {:error, :not_pending}

handoff()

@type handoff() :: admission() | {:error, :not_found}

Functions

active?(state, handler)

Returns whether a handler has running, queued, or pending work.

active_activity?(state, activity)

@spec active_activity?(MingaEditor.EffectScheduler.State.t(), atom()) :: boolean()

Returns whether any active request advertises a semantic activity.

active_source?(state, source)

Returns whether a source has running, queued, or pending work.

admitted?(state, request_id)

Returns whether an exact request still holds scheduler admission.

attach(state, owner)

@spec attach(MingaEditor.EffectScheduler.State.t(), pid()) ::
  {:ok | {:error, :already_attached}, MingaEditor.EffectScheduler.State.t()}

Attaches the scheduler's single owner.

cancel(state, request_id)

Cancels an admitted request.

cancel_operation(state, operation_id)

@spec cancel_operation(
  MingaEditor.EffectScheduler.State.t(),
  MingaEditor.State.Operation.id()
) ::
  {:ok | {:error, :not_found}, MingaEditor.EffectScheduler.State.t()}

Cancels the admitted request correlated with a semantic operation.

cancel_resource(state, resource)

Cancels and terminalizes all work for one semantic resource.

cancel_source(state, source)

Cancels and terminalizes all work attributed to a contribution source.

claim(state, outcome)

Atomically claims a still-pending candidate without releasing its resource.

finalize(state, outcome)

Finalizes a domain-applied candidate, if it is still pending.

finalize_and_schedule(state, outcome, request)

Finalizes a candidate and admits its follow-up as one scheduler transition.

process_down(state, ref, owner, reason)

Processes an owner or worker DOWN message.

schedule(state, request)

Admits a request according to its resource policy.

shutdown(state, reason)

Stops all work and terminalizes every admitted request.

stats(state)

Returns bounded scheduler statistics.

task_result(state, task_ref, result)

Processes a successful worker reply.

timeout(state, request_id)

Processes a scheduler-owned request timeout.