|
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 | + orchestration_set_kv_value, |
| 20 | + orchestration_get_kv_value, |
| 21 | + orchestration_get_kv_all_values, |
| 22 | + orchestration_get_kv_all_keys, |
| 23 | + orchestration_get_kv_length, |
| 24 | + orchestration_clear_kv_value, |
| 25 | + orchestration_clear_all_kv_values, |
| 26 | + orchestration_prune_kv_values, |
23 | 27 | activity_trace_log, |
24 | 28 | activity_is_cancelled, |
25 | 29 | activity_tag, |
@@ -459,23 +463,39 @@ def get_custom_status(self) -> Optional[str]: |
459 | 463 | """ |
460 | 464 | return orchestration_get_custom_status(self.instance_id) |
461 | 465 |
|
462 | | - def set_value(self, key: str, value: str): |
| 466 | + def set_kv_value(self, key: str, value: str): |
463 | 467 | """Set a key-value pair scoped to this orchestration instance.""" |
464 | | - orchestration_set_value(self.instance_id, str(key), str(value)) |
| 468 | + orchestration_set_kv_value(self.instance_id, str(key), str(value)) |
465 | 469 |
|
466 | | - def get_value(self, key: str) -> Optional[str]: |
| 470 | + def get_kv_value(self, key: str) -> Optional[str]: |
467 | 471 | """Get the current value for a key. Returns None if not set.""" |
468 | | - return orchestration_get_value(self.instance_id, str(key)) |
| 472 | + return orchestration_get_kv_value(self.instance_id, str(key)) |
469 | 473 |
|
470 | | - def clear_value(self, key: str): |
| 474 | + def get_kv_all_values(self) -> dict[str, str]: |
| 475 | + """Return a snapshot of all key-value pairs for this orchestration instance.""" |
| 476 | + return orchestration_get_kv_all_values(self.instance_id) |
| 477 | + |
| 478 | + def get_kv_all_keys(self) -> list[str]: |
| 479 | + """Return the list of KV keys currently set on this orchestration instance.""" |
| 480 | + return orchestration_get_kv_all_keys(self.instance_id) |
| 481 | + |
| 482 | + def get_kv_length(self) -> int: |
| 483 | + """Return the number of KV entries currently set on this orchestration instance.""" |
| 484 | + return orchestration_get_kv_length(self.instance_id) |
| 485 | + |
| 486 | + def clear_kv_value(self, key: str): |
471 | 487 | """Remove a single key from the KV store.""" |
472 | | - orchestration_clear_value(self.instance_id, str(key)) |
| 488 | + orchestration_clear_kv_value(self.instance_id, str(key)) |
473 | 489 |
|
474 | | - def clear_all_values(self): |
| 490 | + def clear_all_kv_values(self): |
475 | 491 | """Clear ALL key-value pairs for this orchestration instance.""" |
476 | | - orchestration_clear_all_values(self.instance_id) |
| 492 | + orchestration_clear_all_kv_values(self.instance_id) |
| 493 | + |
| 494 | + def prune_kv_values_updated_before(self, cutoff_ms: int) -> int: |
| 495 | + """Prune KV entries whose last persisted update is older than cutoff_ms.""" |
| 496 | + return orchestration_prune_kv_values(self.instance_id, cutoff_ms) |
477 | 497 |
|
478 | | - def get_value_from_instance(self, instance_id: str, key: str) -> ScheduledTask: |
| 498 | + def get_kv_value_from_instance(self, instance_id: str, key: str) -> ScheduledTask: |
479 | 499 | """Read a KV value from another orchestration instance via the built-in syscall activity.""" |
480 | 500 | return ScheduledTask({ |
481 | 501 | "type": "activity", |
|
0 commit comments