Skip to content

Commit

Permalink
Persister docs (#70)
Browse files Browse the repository at this point in the history
* Detail documentation for the Persister API

Writing my own persister, I ran into some unclarities in the docs,
in combination with unexpected behaviour from the DBI persister.

* Fix the DBI persister to adhere to the protocol
  • Loading branch information
ehuelsmann committed Jan 28, 2021
1 parent 20a7412 commit 3e389fd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/Workflow/Persister.pm
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,25 @@ Persister. Since this is a SUPER class.
Generate an ID for the workflow, serialize the workflow data (ID and
state) and set the ID in the workflow.
Returns the ID for the workflow.
=head3 update_workflow( $workflow )
Stub that warns that the method should be overwritten in the derived
Persister. Since this is a SUPER class.
Update the workflow state.
Returns nothing.
=head3 fetch_workflow( $workflow_id )
Stub that warns that the method should be overwritten in the derived
Persister. Since this is a SUPER class.
Retrieve the workflow data corresponding to C<$workflow_id>. It not
found return undef, if found return a hashref with the data.
found return undef, if found return a hashref with at least the keys
C<state> and C<last_update> (a L<DateTime> instance).
=head3 create_history( $workflow, @history )
Expand All @@ -222,6 +227,9 @@ Persister. Since this is a SUPER class.
Serialize all objects in C<@history> for later retrieval.
Returns C<@history>, the list of history objects, with the history
C<id> and C<saved> values set according to the saved results.
=head3 fetch_history( $workflow )
Stub that warns that the method should be overwritten in the derived
Expand Down
2 changes: 2 additions & 0 deletions lib/Workflow/Persister/DBI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ sub create_workflow {
}
}
$sth->finish;

$wf->id($id);
return $id;
}

Expand Down
1 change: 1 addition & 0 deletions lib/Workflow/Persister/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ sub create_workflow {
my $full_history_path = $self->_get_history_path($wf);
mkdir( $full_history_path, 0777 )
|| persist_error "Cannot create history dir '$full_history_path': $!";

return $wf_id;
}

Expand Down

0 comments on commit 3e389fd

Please sign in to comment.