Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class WorkflowMutableInstance implements WorkflowInstance {
protected AtomicReference<CompletableFuture<WorkflowModel>> futureRef = new AtomicReference<>();
protected Instant completedAt;

private Map<String, Object> additionalObjects = new ConcurrentHashMap<>();
protected Map<String, Object> additionalObjects = new ConcurrentHashMap<>();

protected final Map<String, Integer> iterationsMap = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -448,10 +448,6 @@ public void addCancelable(CompletableFuture<?> cancelable) {
}
}

protected void setMetadata(Map<String, Object> metadata) {
this.additionalObjects = new ConcurrentHashMap<>(metadata);
}

@Override
public <T> T addMetadataIfAbsent(String key, Supplier<T> supplier) {
return (T) additionalObjects.computeIfAbsent(key, k -> supplier.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@
*/
package io.serverlessworkflow.impl.persistence;

public interface PersistenceTaskInfo {}
import java.util.Map;

public interface PersistenceTaskInfo {

Map<String, Object> additionalObjects();
Comment thread
fjtirado marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import java.util.Map;

public record RetriedTaskInfo(int retryAttempt, Map<String, Object> metadata)
public record RetriedTaskInfo(int retryAttempt, Map<String, Object> additionalObjects)
implements PersistenceTaskInfo {
Comment thread
fjtirado marked this conversation as resolved.
public RetriedTaskInfo(int retryAttempt) {
this(retryAttempt, Map.of());
Expand Down
Comment thread
fjtirado marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private WorkflowPersistenceInstance(WorkflowDefinition definition, PersistenceWo
}
});
this.startedAt = info.startedAt();
setMetadata(info.metadata());
additionalObjects = info.metadata();
Comment thread
fjtirado marked this conversation as resolved.
Outdated
}

@Override
Expand Down Expand Up @@ -84,7 +84,6 @@ public void restoreContext(WorkflowContext workflow, TaskContext context) {
: workflow.definition().taskExecutor(completedTaskInfo.nextPosition()),
completedTaskInfo.isEndNode()));
workflow.context(completedTaskInfo.context());
setMetadata(completedTaskInfo.additionalObjects());
} else if (taskInfo instanceof RetriedTaskInfo retriedTaskInfo) {
if (context.retryAttempt() == 0) {
context.retryAttempt(retriedTaskInfo.retryAttempt());
Expand All @@ -100,7 +99,7 @@ public void restoreContext(WorkflowContext workflow, TaskContext context) {
}
searchContext = tryContext.parent();
}
setMetadata(retriedTaskInfo.metadata());
}
taskInfo.additionalObjects().forEach(additionalObjects::put);
Comment thread
fjtirado marked this conversation as resolved.
Outdated
}
}
Loading