You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: custom_worker_tuner/README.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,19 @@ A `CustomSlotSupplier` is a sample that lets you gate slot grants on whatever yo
4
4
This sample gates on a fake DB pool: the worker only polls for a new
5
5
activity when the pool has a free connection.
6
6
7
+
**Note:** This sample is illustrative only. It shouldn't be used for production grade use-cases.
8
+
7
9
## What this sample is
8
-
db_pool.py - A static-capacity counter. Pretends to be a DB pool. Two methods: increment() (claim a slot, returns False if full), decrement() (release)
9
-
supplier.py - The custom slot supplier. On reserve_slot it polls downstream.increment() until it succeeds. On release_slot it calls downstream.decrement()
10
+
db_pool.py - A fixed-capacity fake pool backed by a `BoundedSemaphore`. Two methods: `acquire(blocking=True)` (claim a slot, returns False if full when non-blocking), `release()` (return a slot)
11
+
supplier.py - The custom slot supplier. `reserve_slot` blocks on `connection_pool.acquire()` until a slot is free; `try_reserve_slot` does the same non-blocking. `release_slot`calls `connection_pool.release()`
10
12
shared.py - A RunBatch workflow that runs N do_work activities in parallel. The activity just sleeps
11
-
worker.py - Wires Downstream + DownstreamAwareSupplier into a WorkerTuner
13
+
worker.py - Wires `FakeDatabaseConnectionPool` + `PoolSlotSupplier` into a WorkerTuner
12
14
starter.py - Drives load
13
15
14
16
The flow:
15
17
16
-
When the downstream is at capacity, `reserve_slot` blocks until a
17
-
slot frees up. The excess work piles up on the Temporal server, not
18
+
When the pool is at capacity, `reserve_slot` blocks until a
19
+
connection frees up. The excess work piles up on the Temporal server, not
18
20
inside the worker.
19
21
20
22
## Run
@@ -63,8 +65,7 @@ we chose 10 because default there are 5 pollers for python sdk
63
65
64
66
worker.py:
65
67
66
-
CAPACITY — downstream capacity (the gate)
67
-
POLL_INTERVAL_MS — how often the supplier rechecks when full
0 commit comments