DoubleEntryLedger.CommandQueue.InstanceProcessor (double_entry_ledger v0.1.0)

View Source

Handles processing of commands for a specific instance.

The InstanceProcessor is responsible for fetching, processing, and updating the status of commands belonging to a single instance. It is started dynamically by the InstanceMonitor when there are queued commands to process.

Responsibilities

  • Fetch pending, failed, or timed-out commands for the assigned instance.
  • Process each command and update its status in the database.
  • Handle retries and error cases according to command queue logic.
  • Ensure only one processor runs per instance at a time (enforced via Registry).

This module is typically supervised under the InstanceSupervisor as a dynamic child.

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts an instance processor for the specified instance.

Creates a via tuple for registry-based naming.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

Starts an instance processor for the specified instance.

Parameters

  • opts - Keyword list of options where:
    • :instance_id - Required UUID of the instance to process commands for

Returns

  • {:ok, pid} - Successfully started the processor
  • {:error, reason} - Failed to start the processor

via_tuple(instance_id)

Creates a via tuple for registry-based naming.

Parameters

  • instance_id - UUID of the instance to create a name for

Returns

  • A tuple in the format expected by Registry for process lookup