-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtypes.rs
More file actions
314 lines (296 loc) · 8.6 KB
/
types.rs
File metadata and controls
314 lines (296 loc) · 8.6 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
/// A scheduled task descriptor yielded from orchestration generators.
/// The Rust runtime executes these using the real OrchestrationContext.
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum ScheduledTask {
#[serde(rename = "activity")]
Activity {
name: String,
input: String,
#[serde(skip_serializing_if = "Option::is_none")]
tag: Option<String>,
},
#[serde(rename = "activityWithSession")]
ActivityWithSession {
name: String,
input: String,
#[serde(rename = "sessionId")]
session_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
tag: Option<String>,
},
#[serde(rename = "activityWithRetry")]
ActivityWithRetry {
name: String,
input: String,
retry: RetryPolicyConfig,
#[serde(skip_serializing_if = "Option::is_none")]
tag: Option<String>,
},
#[serde(rename = "timer")]
Timer {
#[serde(rename = "delayMs")]
delay_ms: u64,
},
#[serde(rename = "waitEvent")]
WaitEvent { name: String },
#[serde(rename = "subOrchestration")]
SubOrchestration { name: String, input: String },
#[serde(rename = "subOrchestrationWithId")]
SubOrchestrationWithId {
name: String,
#[serde(rename = "instanceId")]
instance_id: String,
input: String,
},
#[serde(rename = "subOrchestrationVersioned")]
SubOrchestrationVersioned {
name: String,
version: Option<String>,
input: String,
},
#[serde(rename = "subOrchestrationVersionedWithId")]
SubOrchestrationVersionedWithId {
name: String,
version: Option<String>,
#[serde(rename = "instanceId")]
instance_id: String,
input: String,
},
#[serde(rename = "orchestration")]
Orchestration {
name: String,
#[serde(rename = "instanceId")]
instance_id: String,
input: String,
},
#[serde(rename = "orchestrationVersioned")]
OrchestrationVersioned {
name: String,
version: Option<String>,
#[serde(rename = "instanceId")]
instance_id: String,
input: String,
},
#[serde(rename = "newGuid")]
NewGuid,
#[serde(rename = "utcNow")]
UtcNow,
#[serde(rename = "continueAsNew")]
ContinueAsNew { input: String },
#[serde(rename = "continueAsNewVersioned")]
ContinueAsNewVersioned {
input: String,
version: Option<String>,
},
#[serde(rename = "dequeueEvent")]
DequeueEvent {
#[serde(rename = "queueName")]
queue_name: String,
},
#[serde(rename = "activityWithRetryOnSession")]
ActivityWithRetryOnSession {
name: String,
input: String,
retry: RetryPolicyConfig,
#[serde(rename = "sessionId")]
session_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
tag: Option<String>,
},
#[serde(rename = "join")]
Join { tasks: Vec<ScheduledTask> },
#[serde(rename = "select")]
Select { tasks: Vec<ScheduledTask> },
}
#[derive(Debug, Serialize, Deserialize)]
pub struct RetryPolicyConfig {
#[serde(rename = "maxAttempts")]
pub max_attempts: u32,
#[serde(rename = "timeoutMs")]
pub timeout_ms: Option<u64>,
#[serde(rename = "totalTimeoutMs")]
pub total_timeout_ms: Option<u64>,
pub backoff: Option<String>,
}
/// Result of driving a generator one step.
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "status")]
pub enum GeneratorStepResult {
#[serde(rename = "yielded")]
Yielded {
#[serde(rename = "generatorId")]
generator_id: u64,
task: ScheduledTask,
},
#[serde(rename = "completed")]
Completed { output: String },
#[serde(rename = "error")]
Error { message: String },
}
/// Orchestration status returned to Python.
#[pyclass(name = "OrchestrationStatus", get_all, set_all)]
#[derive(Debug, Clone)]
pub struct PyOrchestrationStatus {
pub status: String,
pub output: Option<String>,
pub error: Option<String>,
pub custom_status: Option<String>,
pub custom_status_version: u64,
}
/// System metrics returned to Python.
#[pyclass(name = "SystemMetrics", get_all)]
#[derive(Debug, Clone)]
pub struct PySystemMetrics {
pub total_instances: i64,
pub total_executions: i64,
pub running_instances: i64,
pub completed_instances: i64,
pub failed_instances: i64,
pub total_events: i64,
}
/// Per-orchestration runtime stats returned to Python.
#[pyclass(name = "SystemStats", get_all)]
#[derive(Debug, Clone)]
pub struct PySystemStats {
pub history_event_count: i64,
pub history_size_bytes: i64,
pub queue_pending_count: i64,
pub kv_user_key_count: i64,
pub kv_total_value_bytes: i64,
}
/// Queue depths returned to Python.
#[pyclass(name = "QueueDepths", get_all)]
#[derive(Debug, Clone)]
pub struct PyQueueDepths {
pub orchestrator_queue: i64,
pub worker_queue: i64,
pub timer_queue: i64,
}
/// Instance info returned to Python.
#[pyclass(name = "InstanceInfo", get_all, set_all)]
#[derive(Debug, Clone)]
pub struct PyInstanceInfo {
pub instance_id: String,
pub orchestration_name: String,
pub orchestration_version: String,
pub current_execution_id: i64,
pub status: String,
pub output: Option<String>,
pub created_at: i64,
pub updated_at: i64,
pub parent_instance_id: Option<String>,
}
/// Execution info returned to Python.
#[pyclass(name = "ExecutionInfo", get_all, set_all)]
#[derive(Debug, Clone)]
pub struct PyExecutionInfo {
pub execution_id: i64,
pub status: String,
pub output: Option<String>,
pub started_at: i64,
pub completed_at: Option<i64>,
pub event_count: i64,
}
/// Instance tree returned to Python.
#[pyclass(name = "InstanceTree", get_all)]
#[derive(Debug, Clone)]
pub struct PyInstanceTree {
pub root_id: String,
pub all_ids: Vec<String>,
pub size: i64,
}
/// Delete result returned to Python.
#[pyclass(name = "DeleteInstanceResult", get_all)]
#[derive(Debug, Clone)]
pub struct PyDeleteInstanceResult {
pub instances_deleted: i64,
pub executions_deleted: i64,
pub events_deleted: i64,
pub queue_messages_deleted: i64,
}
/// Prune options from Python.
#[pyclass(name = "PruneOptions", get_all)]
#[derive(Debug, Clone)]
pub struct PyPruneOptions {
pub keep_last: Option<i64>,
pub completed_before: Option<i64>,
}
#[pymethods]
impl PyPruneOptions {
#[new]
#[pyo3(signature = (keep_last=None, completed_before=None))]
fn new(keep_last: Option<i64>, completed_before: Option<i64>) -> Self {
Self {
keep_last,
completed_before,
}
}
}
/// Prune result returned to Python.
#[pyclass(name = "PruneResult", get_all)]
#[derive(Debug, Clone)]
pub struct PyPruneResult {
pub instances_processed: i64,
pub executions_deleted: i64,
pub events_deleted: i64,
}
/// Instance filter from Python.
#[pyclass(name = "InstanceFilter", get_all)]
#[derive(Debug, Clone)]
pub struct PyInstanceFilter {
pub instance_ids: Option<Vec<String>>,
pub completed_before: Option<i64>,
pub limit: Option<i64>,
}
#[pymethods]
impl PyInstanceFilter {
#[new]
#[pyo3(signature = (instance_ids=None, completed_before=None, limit=None))]
fn new(
instance_ids: Option<Vec<String>>,
completed_before: Option<i64>,
limit: Option<i64>,
) -> Self {
Self {
instance_ids,
completed_before,
limit,
}
}
}
/// Runtime metrics snapshot returned to Python.
#[pyclass(name = "MetricsSnapshot", get_all)]
#[derive(Debug, Clone)]
pub struct PyMetricsSnapshot {
pub orch_starts: u64,
pub orch_completions: u64,
pub orch_failures: u64,
pub orch_application_errors: u64,
pub orch_infrastructure_errors: u64,
pub orch_configuration_errors: u64,
pub orch_poison: u64,
pub activity_success: u64,
pub activity_app_errors: u64,
pub activity_infra_errors: u64,
pub activity_config_errors: u64,
pub activity_poison: u64,
pub orch_dispatcher_items_fetched: u64,
pub worker_dispatcher_items_fetched: u64,
pub orch_continue_as_new: u64,
pub suborchestration_calls: u64,
pub provider_errors: u64,
}
/// A single history event returned to Python.
#[pyclass(name = "Event", get_all)]
#[derive(Debug, Clone)]
pub struct PyEvent {
pub event_id: i64,
pub kind: String,
pub source_event_id: Option<i64>,
pub timestamp_ms: i64,
/// Event-specific data (activity result, input, error, timer fire_at, etc.)
pub data: Option<String>,
}