Workflo...ersister(3)
π Workflow::Persister β the base class for workflow persistence, bestie π
okay so. welcome to the Workflo...ersister(3) page, from your friends in the User Contributed Perl Documentation corner of the world. sit down, grab a boba, we're learning about persisters. no cap, it's actually slay.
β¨ VERSION β¨
this doc? it's describing version 2.09 of this package. periodt. π
πΈ SYNOPSIS πΈ
here's the vibe, in code:
# Associate a workflow with a persister in workflow.yaml
type: Ticket
persister: MainDatabase
state:
...
# Declare a persister in persister.yaml
persister:
- name: MainDatabase
class: Workflow::Persister::DBI
driver: MySQL
dsn: DBI:mysql:database=workflows
user: wf
password: mypass
# Declare a separate persister in other_persister.yaml
persister:
- name: FileSystem
class: Workflow::Persister::File
path: /path/to/my/workflow
likeβ¦ she's just a lil config girlie. iconic. π
π¦ DESCRIPTION π¦
so this is the base class for persisting workflows. and here's the tea: it does not implement anything itself. it's giving abstract. actual implementations are supposed to subclass it so they can fulfil the contract. it's giving interface energy, fr fr.
and what's the job of a persister, you ask? bestie, the job is:
- create, update and fetch the workflow object
- plus any data associated with the workflow
- and it also creates and fetches workflow history records
that's the whole gig. not me describing an entire responsibility set in one breath π
π SUBCLASSING π
β Methods β
create_workflow( $workflow )
this one's a stub, and the stub's whole personality is warning you that the method should be overwritten in the derived Persister. because β say it with me β this is a SUPER class. β¨
what it's supposed to do: generate an ID for the workflow, serialize the workflow data (that's the ID and the state), and set the ID in the workflow.
returns: the ID for the workflow. π
update_workflow( $workflow )
another stub, another warning that you should overwrite it in the derived Persister. because this is a SUPER class. yes we're doing this every time, it's a bit π
what it does: updates the workflow state, which includes serializing the workflow context.
returns: literally nothing. nothing at all. π«Ά
fetch_workflow( $workflow_id )
stub alert π¨ warns you that the derived Persister should overwrite it. since β you guessed it β this is a SUPER class.
what it does: retrieves the workflow data that corresponds to $workflow_id.
- if it's not found, return
undef - if it is found, return a hashref with at least the keys
"state"and"last_update"(and"last_update"is aDateTimeinstance, fancy)
and if the workflow has associated serialized context? then return the deserialized hash value in the "context" key. the keys in that hash get made available through the "param" method in the workflow's context (which you reach through the "context" method). iykyk. π
create_history( $workflow, @history )
stub, warning, overwrite it in the derived Persister, SUPER class, you know the drill bestie π
what it does: serializes all objects in @history so they can be retrieved later.
returns @history β that's the list of history objects β with the history "id" and "saved" values set according to the saved results.
fetch_history( $workflow )
stub, warning, overwrite, SUPER class. ok but actually the derived class method here should return a list of hashes containing at least the id key. those hashes get used by the workflow object to instantiate Workflow::History objects (or a derived class of it). cute, right? π
assign_generators( \%params )
assigns the proper generators based on initialization. see "init". β¨
commit_transaction
commits the current transaction if the persister supports transactions. and good news: this stub does not have to be overridden. π
but heads up β it is not executed if autocommit is on. π
rollback_transaction
rolls back the current transaction if the persister supports transactions. and again, this stub does not have to be overridden. π
and again β it is not executed if autocommit is on.
init
the method to initialize the persister based on configuration. that's it, that's the whole girl. πΈ
init_random_generators( \%params )
initializes random id generators. it takes the following named parameter:
lengthβ of random id to be generated
returns two identical random id generator objects in list context. twins!! π―
init_uuid_generators( \%params )
initializes UUID generators. takes no parameters.
returns two identical UUID generator objects in list context. twins again, but make it UUID. π¦
π TODO π
the maintainers left us a little list of things they're side-eyeing:
- refactor
init_random_generators, returns two similar objects? - refactor
init_uuid_generators, returns two similar objects? - refactor
init_uuid_generators, takes no parameters, even though we shift parameters in?
not me reading the third one twice π the self-awareness is highkey unmatched.
π₯ SEE ALSO π₯
Workflow::FactoryWorkflow::History
go read those too, bestie, they're the supporting cast. π
π COPYRIGHT π
Copyright (c) 2003-2021 Chris Winters. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Please see the LICENSE
π AUTHORS π
Please see Workflow
okay that's the whole page!! and a lil cute sign-off for you: this lovely thing is from perl v5.42.0, dated 2026-01-17, and yeah it's filed under Workflo...ersister(3) β that truncated name is not a typo, that's just how the manpage wears it. slay, go subclass something responsibly π«Άβ¨π
π¦ where this page comes from
- fedora 44: perl-Workflow 2.09-2.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms