Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/goofy-taxes-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@orbi-ts/core': patch
---

don't close successfull once actions in order to keep track of their value
10 changes: 10 additions & 0 deletions core/actions/src/action-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,16 @@ export class Action {
this.dbDoc.markModified('cronActivity.nextActivity');
return this.changeState(ActionState.SLEEPING);
} else if (this.dbDoc.workflowId) {
if (
this.dbDoc.workflowCrossStrategy &&
this.dbDoc.state === ActionState.SUCCESS
) {
this.dbDoc.cronActivity.nextActivity = new Date(
Date.now() + 365 * 24 * 60 * 60 * 1000
);
this.dbDoc.markModified('cronActivity.nextActivity');
return this.dbDoc.save().then(() => ActionState.UNKNOWN); //short circuit
}
return Workflow.findPendingWorkflowUsingAction(this.dbDoc).then(
async (workflowDbs) => {
const trackingResumePromise = [];
Expand Down
11 changes: 11 additions & 0 deletions core/actions/src/coalescing-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ export abstract class CoalescingWorkflow extends Workflow {
const actions = await ActionRuntime.activeRuntime.ActionModel.find({
workflowRef: ref,
workflowIdentity: this.stringifyIdentity(),
state: {
$lte: ActionState.SUCCESS, //we do not retain ERROR, only SUCCESS are shared
},
}).sort('createdAt');
for (const action of actions) {
if (!this.registeredActionIds.includes(action.id)) {
Expand Down Expand Up @@ -127,6 +130,14 @@ export abstract class CoalescingWorkflow extends Workflow {
return super.do(ref, opts);
}

trackAction(ref: string, action: ActionSchemaInterface) {
const strategy = this.mapRefWithStrategy.get(ref);
if (strategy === 'cross-workflow') {
action.workflowCrossStrategy = true;
}
return super.trackAction(ref, action);
}

async lastOutput() {
const oldActions = await ActionRuntime.activeRuntime.ActionModel.find({
identity: this.stringifyIdentity(),
Expand Down
2 changes: 2 additions & 0 deletions core/actions/src/models/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface ActionSchemaInterface<
workflowRef?: string;
workflowIteration?: number;
workflowIdentity?: string;
workflowCrossStrategy?: boolean;
workflowStack: {
ref: string;
stepIndex: number;
Expand Down Expand Up @@ -94,6 +95,7 @@ export const actionSchema = new mongoose.Schema(
workflowRef: String,
workflowIteration: Number,
workflowIdentity: String,
workflowCrossStrategy: Boolean,
generatorCount: Number,
workflowStack: [
{
Expand Down
2 changes: 1 addition & 1 deletion core/actions/src/workflow-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export class Workflow extends Action {
return this.trackDefine();
}

private trackAction(ref: string, action: ActionSchemaInterface) {
protected trackAction(ref: string, action: ActionSchemaInterface) {
this.registeredActionIds.push(action.id);
if (
!this.bag.registeredActions.find((descriptor) => {
Expand Down