forked from OptimalBits/bull
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.js
More file actions
48 lines (34 loc) · 1.01 KB
/
Copy pathstate.js
File metadata and controls
48 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
State machine.
Distributed state machine.
*/
var machine = Machine('signup', opts); // opts -> redis connection mostly, name of the machine.
machine.state('send mail', function(data, next){
// In this state we send an email with a confirmation link and exit the state
next('wait confirmation', data);
});
machine.state('wait confirmation'); // // In this state we do nothing we just wait for an external input
machine.state('confirm user', function(task){
return data;
})
machine.next('wait confirmation', data);
/**
queue('wait confirmation').add(data);
*/
machine.state('transcode video', function(data){
// transcode...
this.next('append moov');
}).catch(function(err){
this.next('delete tmp');
});
machine.state('append moov', input, function(data, next){
// Append MOOV etc.
this.next('delete tmp');
});
machine.next('delete temp', input, function(data, next){
// delete temp file
this.next('update user account');
});
machine.state('update user account', function(data, next){
// update database
});