-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger-workflow-example.yaml
More file actions
192 lines (171 loc) · 4.47 KB
/
trigger-workflow-example.yaml
File metadata and controls
192 lines (171 loc) · 4.47 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
requires:
plugins:
- name: api
- name: messaging
- name: modular-compat
- name: statemachine
- name: workflow-plugin-http
modules:
# HTTP infrastructure
- name: api-http-server
type: http.server
config:
address: ":8080"
- name: api-router
type: http.router
dependsOn:
- api-http-server
# Authentication middleware
- name: auth-middleware
type: http.middleware.auth
config:
secretKey: "my-secret-key"
# Messaging infrastructure
- name: message-broker
type: messaging.broker
# Scheduler for timed operations
- name: cron-scheduler
type: scheduler.modular
# API handlers
- name: users-api
type: api.handler
config:
resourceName: "users"
- name: products-api
type: api.handler
config:
resourceName: "products"
- name: orders-api
type: api.handler
config:
resourceName: "orders"
- name: health-api
type: http.handler
config:
contentType: "application/json"
# Messaging handlers
- name: user-event-handler
type: messaging.handler
- name: order-processor
type: messaging.handler
- name: inventory-updater
type: messaging.handler
- name: notification-service
type: messaging.handler
# State machine for order processing
- name: order-state-machine
type: statemachine.engine
config:
description: "Processes orders through their lifecycle"
workflows:
http:
routes:
# Public endpoints
- method: GET
path: /health
handler: health-api
# Protected endpoints
- method: GET
path: /api/users
handler: users-api
middlewares:
- auth-middleware
- method: POST
path: /api/users
handler: users-api
middlewares:
- auth-middleware
- method: GET
path: /api/products
handler: products-api
middlewares:
- auth-middleware
- method: GET
path: /api/orders
handler: orders-api
middlewares:
- auth-middleware
- method: POST
path: /api/orders
handler: orders-api
middlewares:
- auth-middleware
messaging:
subscriptions:
- topic: user-events
handler: user-event-handler
- topic: order-events
handler: order-processor
- topic: inventory-updates
handler: inventory-updater
- topic: notifications
handler: notification-service
statemachine:
engine: order-state-machine
definitions:
- name: order-workflow
description: "Order processing workflow"
initialState: "new"
states:
new:
description: "New order"
isFinal: false
processing:
description: "Order is being processed"
isFinal: false
completed:
description: "Order has been completed"
isFinal: true
cancelled:
description: "Order was cancelled"
isFinal: true
transitions:
submit_order:
fromState: "new"
toState: "processing"
complete_order:
fromState: "processing"
toState: "completed"
cancel_order:
fromState: "processing"
toState: "cancelled"
# New section for triggers
triggers:
http:
routes:
- path: "/api/workflows/orders/submit"
method: "POST"
workflow: "order-workflow"
action: "submit_order"
- path: "/api/workflows/orders/:id/complete"
method: "POST"
workflow: "order-workflow"
action: "complete_order"
- path: "/api/workflows/orders/:id/cancel"
method: "POST"
workflow: "order-workflow"
action: "cancel_order"
schedule:
jobs:
- cron: "0 * * * *" # Every hour
workflow: "order-workflow"
action: "process_pending_orders"
params:
batchSize: 100
- cron: "0 0 * * *" # Every day at midnight
workflow: "inventory-workflow"
action: "daily_inventory_check"
event:
subscriptions:
- topic: "order-events"
event: "order.created"
workflow: "order-workflow"
action: "submit_order"
- topic: "order-events"
event: "order.payment_received"
workflow: "order-workflow"
action: "complete_order"
- topic: "order-events"
event: "order.cancelled"
workflow: "order-workflow"
action: "cancel_order"