Skip to content

Commit 104fbe9

Browse files
affandarCopilot
andcommitted
Bump duroxide to 0.1.26, duroxide-pg to 0.1.27, add KV RMW counter test
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0ec03c2 commit 104fbe9

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ name = "duroxide_python"
88
crate-type = ["cdylib"]
99

1010
[dependencies]
11-
duroxide = { version = "0.1.25", features = ["sqlite"] }
12-
duroxide-pg = { version = "0.1.26" }
11+
duroxide = { version = "0.1.26", features = ["sqlite"] }
12+
duroxide-pg = { version = "0.1.27" }
1313
pyo3 = { version = "0.23", features = ["extension-module"] }
1414
async-trait = "0.1"
1515
tokio = { version = "1", features = ["full"] }

tests/test_kv_store.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,37 @@ def consumer(ctx, producer_id):
179179
assert client.get_kv_value(producer_id, "status") == "done"
180180
finally:
181181
runtime.shutdown(100)
182+
183+
184+
def test_kv_read_modify_write_counter(provider):
185+
client = Client(provider)
186+
runtime = Runtime(provider, PyRuntimeOptions(dispatcher_poll_interval_ms=50))
187+
188+
@runtime.register_activity("ProcessBatch")
189+
def process_batch(_ctx, input):
190+
return f"processed:{input}"
191+
192+
@runtime.register_orchestration("BatchProcessor")
193+
def batch_processor(ctx, _input):
194+
for batch_name in ["alpha", "beta", "gamma"]:
195+
processed = int(ctx.get_kv_value("batches_processed") or "0")
196+
result = yield ctx.schedule_activity("ProcessBatch", batch_name)
197+
ctx.set_kv_value("batches_processed", str(processed + 1))
198+
ctx.set_kv_value("last_result", result)
199+
200+
return ctx.get_kv_value("batches_processed") or "0"
201+
202+
runtime.start()
203+
204+
try:
205+
instance_id = uid("batch-processor")
206+
client.start_orchestration(instance_id, "BatchProcessor", "")
207+
208+
result = client.wait_for_orchestration(instance_id, 5_000)
209+
assert result.status == "Completed"
210+
assert result.output == "3"
211+
212+
assert client.get_kv_value(instance_id, "batches_processed") == "3"
213+
assert client.get_kv_value(instance_id, "last_result") == "processed:gamma"
214+
finally:
215+
runtime.shutdown(100)

0 commit comments

Comments
 (0)