|
16 | 16 | orchestration_set_custom_status, |
17 | 17 | orchestration_reset_custom_status, |
18 | 18 | orchestration_get_custom_status, |
| 19 | + orchestration_set_value, |
| 20 | + orchestration_get_value, |
| 21 | + orchestration_clear_value, |
| 22 | + orchestration_clear_all_values, |
19 | 23 | activity_trace_log, |
20 | 24 | activity_is_cancelled, |
21 | 25 | activity_tag, |
@@ -455,6 +459,30 @@ def get_custom_status(self) -> Optional[str]: |
455 | 459 | """ |
456 | 460 | return orchestration_get_custom_status(self.instance_id) |
457 | 461 |
|
| 462 | + def set_value(self, key: str, value: str): |
| 463 | + """Set a key-value pair scoped to this orchestration instance.""" |
| 464 | + orchestration_set_value(self.instance_id, str(key), str(value)) |
| 465 | + |
| 466 | + def get_value(self, key: str) -> Optional[str]: |
| 467 | + """Get the current value for a key. Returns None if not set.""" |
| 468 | + return orchestration_get_value(self.instance_id, str(key)) |
| 469 | + |
| 470 | + def clear_value(self, key: str): |
| 471 | + """Remove a single key from the KV store.""" |
| 472 | + orchestration_clear_value(self.instance_id, str(key)) |
| 473 | + |
| 474 | + def clear_all_values(self): |
| 475 | + """Clear ALL key-value pairs for this orchestration instance.""" |
| 476 | + orchestration_clear_all_values(self.instance_id) |
| 477 | + |
| 478 | + def get_value_from_instance(self, instance_id: str, key: str) -> ScheduledTask: |
| 479 | + """Read a KV value from another orchestration instance via the built-in syscall activity.""" |
| 480 | + return ScheduledTask({ |
| 481 | + "type": "activity", |
| 482 | + "name": "__duroxide_syscall:get_kv_value", |
| 483 | + "input": json.dumps({"instance_id": instance_id, "key": key}), |
| 484 | + }) |
| 485 | + |
458 | 486 | # ─── Logging (fire-and-forget, delegates to Rust ctx.trace()) ─── |
459 | 487 |
|
460 | 488 | def trace_info(self, message: str): |
|
0 commit comments