mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-02 10:43:08 +00:00
## What changed? Added rate limiting for persistence calls for history replication system. ## Why? This allows us to limit the impact of replication spikes on the persistence layer. ## How did you test it? - [x] built - [ ] run locally and tested manually - [ ] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) --- > [!NOTE] > Introduce a persistence request rate limiter used before `AppendRawHistoryNodes` during workflow state replication and backfill, wired through history engine and replication module. > > - **History Replication (NDC)**: > - `WorkflowStateReplicatorImpl` now takes `quotas.RequestRateLimiter` and issues `Wait` calls before `executionMgr.AppendRawHistoryNodes` in `bringLocalEventsUpToSourceCurrentBranch` and `backfillHistory` using namespace-aware quota requests. > - **Wiring/DI**: > - `NewWorkflowStateReplicator` and `NewEngineWithShardContext` accept `persistenceRateLimiter`; `history_engine_factory` passes it through. > - Add `PersistenceRateLimiter` type and `PersistenceRateLimiterProvider` (noop) in `service/history/replication` and include in `fx` module. > - **Tests**: > - Update tests to pass `quotas.NoopRequestRateLimiter` and stub namespace name lookups where needed. > > <sup>Written by [Cursor Bugbot]() for commit 38b76e759100905d5d475d74070826e5aa968be8. This will update automatically on new commits. Configure [here]().</sup>
30 lines
684 B
Go
30 lines
684 B
Go
package replication
|
|
|
|
import (
|
|
"go.temporal.io/server/common/quotas"
|
|
)
|
|
|
|
const (
|
|
taskSchedulerToken = 1
|
|
)
|
|
|
|
type (
|
|
ServerSchedulerRateLimiter quotas.RequestRateLimiter
|
|
ClientSchedulerRateLimiter quotas.RequestRateLimiter
|
|
PersistenceRateLimiter quotas.RequestRateLimiter
|
|
)
|
|
|
|
func ClientSchedulerRateLimiterProvider() ClientSchedulerRateLimiter {
|
|
// Experiment with no op rate limiter
|
|
return quotas.NoopRequestRateLimiter
|
|
}
|
|
|
|
func ServerSchedulerRateLimiterProvider() ServerSchedulerRateLimiter {
|
|
// Experiment with no op rate limiter
|
|
return quotas.NoopRequestRateLimiter
|
|
}
|
|
|
|
func PersistenceRateLimiterProvider() PersistenceRateLimiter {
|
|
return quotas.NoopRequestRateLimiter
|
|
}
|