Skip to content

Commit fbae213

Browse files
authored
Document business process events (#30)
1 parent 60b8e1f commit fbae213

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Business Process
2+
3+
## Initialization
4+
5+
```mermaid
6+
sequenceDiagram
7+
participant PBPM as PassportBusinessProcessManager
8+
participant BP as BusinessProcess.initialize
9+
10+
note over PBPM: create passport business process
11+
PBPM ->> BP: new BusinessProcess(steps, transitions)
12+
note over BP: @steps = steps
13+
note over BP: @transitions = transitions
14+
note over BP: hook up event listeners
15+
note over BP: for event_name in get_event_names() subscribe(event_name, self.handle_event)
16+
17+
BP ->> PBPM: return
18+
```
19+
20+
## Response to event
21+
22+
```mermaid
23+
sequenceDiagram
24+
actor U as User
25+
participant BP as BusinessProcess.handle_event
26+
participant V as VerifyIdentityStep.execute
27+
participant R as ReviewPhotoStep.execute
28+
29+
note over U: user submits application
30+
U ->> BP: publish("app_submitted", PassportCase.find(app.case_id))
31+
32+
note over BP: next_step = @transitions[kase.current_step][event_name]
33+
note over BP: kase.current_step = next_step
34+
35+
BP ->> V: @steps[next_step].execute(kase)
36+
note over V: create a task
37+
38+
note over U: admin verifies identity
39+
U ->> BP: publish("identity_verified", kase)
40+
41+
note over BP: next_step = @transitions[kase.current_step][event_name]
42+
note over BP: kase.current_step = next_step
43+
44+
BP ->> R: @steps[next_step].execute(kase)
45+
note over R: create a task
46+
```

0 commit comments

Comments
 (0)