Carbonite.Outbox.process
process
, go back to Carbonite.Outbox module for more information.
Specs
process([process_option()], process_fun()) :: Ecto.Multi.t()
Builds an Ecto.Multi
that can be used to load Carbonite.Transaction
records from database
(in order of insertion) and process them one-by-one through a function.
Processed items are marked as processed and can be purged.
Options
batch_size
is the size of records to load in one chunk, defaults to 20min_age
is the minimum age of a record, defaults to 300 seconds (see below)prefix
is the Carbonite schema, defaults to"carbonite_default"
Long running transactions & insertion order
A warning: As Carbonite.Transaction
records are inserted at the beginning of a database
transaction, their inserted_at
is already a bit in the past when they become visible to other
connections, e.g. to your processing job. This means that in case of long running transactions,
Carbonite.Transaction
records with more recent inserted_at
values might be processed before
older ones, and hence the eventual total order of inserted_at
in the processed records can
not be guaranteed. To mitigate this issue, Carbonite will by default exclude records younger than
min_age
seconds from processing. Tweak this setting if you have even longer transactions.