Comments (2)
Hi!
To help those asking for the same question, here is an example of a simple logProgress
function.
import { configureWorkflow, IWorkflowHost, WorkflowConfig, IWorkflowRegistry, TYPES, IPersistenceProvider, WorkflowStatus } from 'workflow-es';
// ...
export class HostModule {
private workflowConfig: WorkflowConfig;
constructor() {
this.workflowConfig = configureWorkflow();
this.workflowConfig.registerWorkflow(MyWorkflow1);
this.workflowConfig.registerWorkflow(MyWorkflow2);
}
async logProgress(workflowId: string) {
const container = await this.workflowConfig.getContainer();
const persistence = container.get<IPersistenceProvider>(TYPES.IPersistenceProvider);
const registry = container.get<IWorkflowRegistry>(TYPES.IWorkflowRegistry);
const wf = await persistence.getWorkflowInstance(workflowId);
const wfDefinition = await registry.getDefinition(wf.workflowDefinitionId, wf.version);
console.log("\n\n\n------- wf introspection", `status=${this.getWorkflowStatusKey(wf.status)}`);
console.log(wfDefinition.steps.map(step => `step(${step.id}): ${step.body.name}`));
console.log(`execution pointers steps (${wf.executionPointers.length}) :`);
console.log(wf.executionPointers.map((p, i) => `pointer n°${i} => step(${p.stepId})${p.active ? ' **active**' : ''}`));
}
private getWorkflowStatusKey(value: number): string {
const statuses: { [key: string]: number } = {...WorkflowStatus};
for (let key in statuses) {
if (statuses[key] === value) {
return key
}
}
return "unknown";
}
}
This will log something like this :
// HostModule.logProgress
------- wf introspection status=Runnable
[
'step(0): ConfigurationTask',
'step(1): Foreach',
'step(2): AllocateResourcesTask',
'step(3): Foreach',
'step(4): SetupVaultsTask',
'step(5): Foreach',
'step(6): ServiceCheckTask',
'step(7): ServiceDeployTask',
'step(8): ServiceRestartTask',
'step(9): NginxReloadTask',
'step(10): Foreach',
'step(11): ServiceCleanupTask'
]
execution pointers steps (16) :
[
'pointer n°0 => step(0)',
'pointer n°1 => step(1)',
'pointer n°2 => step(2)',
'pointer n°3 => step(2)',
'pointer n°4 => step(2)',
'pointer n°5 => step(3)',
'pointer n°6 => step(4)',
'pointer n°7 => step(4)',
'pointer n°8 => step(4)',
'pointer n°9 => step(5) **active**',
'pointer n°10 => step(6)',
'pointer n°11 => step(6)',
'pointer n°12 => step(6)',
'pointer n°13 => step(7) **active**',
'pointer n°14 => step(7) **active**',
'pointer n°15 => step(7) **active**'
]
The purpose of this is to give an idea of what to expect before diving into code. I hope someone would find it useful :D
from workflow-es.
Hi,
The Persistence Provider implementations do allow you to retrieve and inspect a single workflow. It would not be hard to add some additional methods to this class to enabled this across multiple workflows. This has been done on Workflow Core which is the sister project (.NET version) of this project.
You can use WorkflowConfig.getContainer
to access to IoC container to access the implementation of this.
from workflow-es.
Related Issues (20)
- No workflow-es-mysql HOT 14
- FYI - imports missing in 06-deferred-steps.ts example HOT 2
- Apparent Bug in 06-deferred-steps.ts HOT 5
- Self Transitions and Feedback loops HOT 1
- load work flow json please HOT 3
- Error handling question HOT 6
- Repeated runnable instances on the same queue HOT 3
- Poll Worker Interval Override HOT 2
- Issue passing data to parallel HOT 2
- Restart workflow HOT 2
- workflow-es-mongodb 2.1.1 was not built before it was published to NPM! HOT 2
- NestJS dependency injection HOT 1
- Error handling HOT 1
- waitFor - multiple events HOT 1
- Workflow never resumed after waitFor HOT 1
- Workflow Engine stops after sometime due to workflow-es-mongodb (getRunnableEvents)
- Output for "waitFor" is executed twice
- How to resume a workflow execution?
- Will it be updated ?
- -
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workflow-es.