class sample extends WorkflowController{
@workflow()
async doA(a){
var x = a;
this.a = 4;
await this.sleep(2);
var b = await this.doB(x);
b = await this.doB(b);
var d= await this.doA2(x);
var wf2 = new sample2(this.newDispatchID());
var e= await wf2.doA3(x*2 + d);
// await this.sleep(2);
// await this.continueAsNew(a+1);
return e;
}
@workflow()
async doA2(a){
var x = a;
var res = await this.doHuman({
prepare:this.prepare,
process:this.process,
id:'human 2',
payload:5
});
var b= await this.doB(x);
return res+b;
}
fireSignal(n,id){
console.log("firing ", id, n);
this.scheduler.signal(id,n);
}
@activity()
async doB(n){
return n * n;
}
@activity()
async process(n,id){
console.log("processing", n,id);
return n * n;
}
@activity()
async prepare(n,id){
console.log("preparing", n , id);
setTimeout(this.fireSignal.bind(this),5000,n,id);
// do something
return;
}
}
class sample2 extends WorkflowController{
@workflow()
async doA3(a){
var x = a;
var b = await this.doB5(x);
var m = await this.waitForSignal("human 1");
// var aa = await this.doX();
return b;
}
fireSignal(){
this.scheduler.signal("human 1","hello");
}
@activity()
async doB5(n){
setTimeout(this.fireSignal.bind(this),2000)
return n * n;
}
@activity()
async doX(){
console.log('doX')
throw new Error('not working');
}
}
schedulerClient.run({className:'sample',name:'doA',args:[5],id:'test1'});
foreverjs
1.1.264 • Public • PublishedVersions
Current Tags
- VersionDownloads (Last 7 Days)
- Tag
- 1.1.2645
- latest
Version History
- VersionDownloads (Last 7 Days)
- Published
- 1.1.2645
- 1.1.2631
- 1.1.2621
- 1.1.2611
- 1.1.2601
- 1.1.2591
- 1.1.2581
- 1.1.2571
- 1.1.2561
- 1.1.2541
- 1.1.2551
- 1.1.2531
- 1.1.2521
- 1.1.2511
- 1.1.2501
- 1.1.2491
- 1.1.2481
- 1.1.2471
- 1.1.2461
- 1.1.2451
- 1.1.2441
- 1.1.2421
- 1.1.2431
- 1.1.2411
- 1.1.2401
- 1.1.2391
- 1.1.2371
- 1.1.2301
- 1.1.2291
- 1.1.2281
- 1.1.2271
- 1.1.2261
- 1.1.2251
- 1.1.2241
- 1.1.2231
- 1.1.2221
- 1.1.2211
- 1.1.2201
- 1.1.2191
- 1.1.2181
- 1.1.2171
- 1.1.2161
- 1.1.2151
- 1.1.2141
- 1.1.2131
- 1.1.2121
- 1.1.2111
- 1.1.2101
- 1.1.2091
- 1.1.2081
- 1.1.2071
- 1.1.2061
- 1.1.2051
- 1.1.2041
- 1.1.2031
- 1.1.2021
- 1.1.2011
- 1.1.2001
- 1.1.1991
- 1.1.1981
- 1.1.1971
- 1.1.1961
- 1.1.1951
- 1.1.1941
- 1.1.1931
- 1.1.1921
- 1.1.1911
- 1.1.1901
- 1.1.1891
- 1.1.1881
- 1.1.1871
- 1.1.1861
- 1.1.1851
- 1.1.1841
- 1.1.1831
- 1.1.1821
- 1.1.1811
- 1.1.1801
- 1.1.1791
- 1.1.1781
- 1.1.1771
- 1.1.1761
- 1.1.1751
- 1.1.1741
- 1.1.1731
- 1.1.1721
- 1.1.1711
- 1.1.1691
- 1.1.1681
- 1.1.1671
- 1.1.1661
- 1.1.1651
- 1.1.1641
- 1.1.1631
- 1.1.1621
- 1.1.1611
- 1.1.1601
- 1.1.1591
- 1.1.1581
- 1.1.1571
- 1.1.1561
- 1.1.1551
- 1.1.1541
- 1.1.1531
- 1.1.1521
- 1.1.1511
- 1.1.1501
- 1.1.1491
- 1.1.1481
- 1.1.1471
- 1.1.1461
- 1.1.1451
- 1.1.1441
- 1.1.1431
- 1.1.1421
- 1.1.1411
- 1.1.1401
- 1.1.1391
- 1.1.1381
- 1.1.1371
- 1.1.1361
- 1.1.1351
- 1.1.1341
- 1.1.1331
- 1.1.1321
- 1.1.1311
- 1.1.1281
- 1.1.1271
- 1.1.1261
- 1.1.1251
- 1.1.1241
- 1.1.1231
- 1.1.1221
- 1.1.1210
- 1.1.1201
- 1.1.1191
- 1.1.1181
- 1.1.1171
- 1.1.1161
- 1.1.1151
- 1.1.1141
- 1.1.1131
- 1.1.1121
- 1.1.1111
- 1.1.1101
- 1.1.1091
- 1.1.1081
- 1.1.1071
- 1.1.1061
- 1.1.1051
- 1.1.1041
- 1.1.1031
- 1.1.1021
- 1.1.1011
- 1.0.91
- 1.0.81
- 1.0.71
- 1.0.61
- 1.0.51
- 1.0.41
- 1.0.31
- 1.0.21
- 1.0.11
Package Sidebar
Install
npm i foreverjs
Repository
Weekly Downloads
166
Version
1.1.264
License
MIT
Unpacked Size
443 kB
Total Files
65