NAME

Schedule::LongSteps::Storage::DBIxClass - DBIx::Class based storage.

SYNOPSIS

First instantiate a storage with your DBIx::Class::Schema and the name of the resultset that represent the stored process:

  my $storage = Schedule::LongSteps::Storage::DBIxClass->new({
                   schema => $dbic_schema,
                   resultset_name => 'LongstepsProcess'
                });

Then build and use a Schedule::LongSteps object:

  my $long_steps = Schedule::LongSteps->new({ storage => $storage });

  ...

ATTRIBUTES

schema

You DBIx::Class::Schema. Mandatory.

resultset_name

The name of the resultset holding the processes in your Schema. See section 'RESULTSET REQUIREMENTS'. Mandatory.

limit_per_tick

The maximum number of processes that will actually run each time you call $longsteps->run_due_processes(). Use that to control how long it takes to run a single call to $longsteps->run_due_processes().

Note that you can have an arbitrary number of processes all doing $longsteps->run_due_processes() AT THE SAME TIME.

This will ensure that no process step is run more than one time.

Default to 50.

RESULTSET REQUIREMENTS

The resultset to use with this storage MUST contain the following columns, constraints and indices:

id

A unique primary key auto incrementable identifier

process_class

A VARCHAR long enough to hold your Schedule::LongSteps::Process class names. NOT NULL.

what

A VARCHAR long enough to hold the name of one of your steps. Can be NULL.

status

A VARCHAR(50) NOT NULL, defaults to 'pending'

run_at

A Datetime (or timestamp with timezone in PgSQL). Will hold a UTC Timezoned date of the next run. Default to NULL.

Please index this so it is fast to select a range.

run_id

A CHAR or VARCHAR (at least 36). Default to NULL.

Please index this so it is fast to select rows with a matching run_id

state

A Reasonably long TEXT field (or JSON field in supporting databases) capable of holding a JSON dump of pure Perl data. NOT NULL.

You HAVE to implement inflating and deflating yourself. See DBIx::Class::InflateColumn::Serializer::JSON or similar techniques.

See t/fullblown.t for a full blown working example.

error

A reasonably long TEXT field capable of holding a full stack trace in case something goes wrong. Defaults to NULL.

prepare_due_processes

See Schedule::LongSteps::Storage::DBIxClass

create_process

See Schedule::LongSteps::Storage

This override adds retrying in case of deadlock detection.

find_process

See Schedule::LongSteps::Storage

update_process

Overrides Schedule::LongSteps::Storage#update_process to add some retrying in case of DB deadlock detection.