Skip to content

Commit

Permalink
Merge pull request #182 from ehuelsmann/persister-context-docs
Browse files Browse the repository at this point in the history
Document persister's handling of workflow context
  • Loading branch information
ehuelsmann committed Jan 24, 2022
2 parents b6ce54a + 41d2438 commit d091ea4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Workflow/Factory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ sub fetch_workflow {
my $wf = $wf_class->new( $wf_id, $wf_info->{state}, $wf_config,
$self->{_workflow_state}{$wf_type}, $self );

$wf->context( $wf_info->{context} || Workflow::Context->new ); #if ( not $wf->context() );
$wf->context( Workflow::Context->new(%{ $wf_info->{context} // {} }) );
$wf->last_update( $wf_info->{last_update} );

$persister->fetch_extra_workflow_data($wf);
Expand Down
8 changes: 7 additions & 1 deletion lib/Workflow/Persister.pm
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ Returns the ID for the workflow.
Stub that warns that the method should be overwritten in the derived
Persister. Since this is a SUPER class.
Update the workflow state.
Update the workflow state including serialization of the workflow
context.
Returns nothing.
Expand All @@ -215,6 +216,11 @@ Retrieve the workflow data corresponding to C<$workflow_id>. It not
found return undef, if found return a hashref with at least the keys
C<state> and C<last_update> (a L<DateTime> instance).
If the workflow has associated serialized context, return the
deserialized hash value in the C<context> key. The keys in the hash
will be made available through the C<param> method in the workflow's
context (accessible through the C<context> method).
=head3 create_history( $workflow, @history )
Stub that warns that the method should be overwritten in the derived
Expand Down
3 changes: 1 addition & 2 deletions lib/Workflow/Persister/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ sub _serialize_workflow {
state => $wf->state,
last_update => $wf->last_update,
type => $wf->type,
context => $wf->context,

context => { %{$wf->context->{PARAMS} } },
);
$self->serialize_object( $full_path, \%wf_info );
$self->log->debug("Wrote workflow ok");
Expand Down

0 comments on commit d091ea4

Please sign in to comment.