Skip to content

Add CircuitBreaker half-open quota replenishment scheduler #664

Description

@greatest0fallt1me

Description

circuit_breaker.rs exposes BreakerState::HalfOpen but does not throttle traffic through it: any call slips while the breaker is half-open. Add a quota-based scheduler so only N calls per minute are admitted in half-open before deciding to fully close or reopen.

Requirements and Context

  • Add HalfOpenQuota { calls_per_minute: u32, evaluation_window_s: u64 } to breaker config
  • Track admission counter under temporary storage
  • On quota exhaustion in window, transition to Closed; on any failure, back to Open
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested Execution

  1. Fork the repo and create a branch
    git checkout -b feature/circuit-breaker-halfopen-quota
  2. Implement changes
    • contracts/predictify-hybrid/src/circuit_breaker.rs
    • contracts/predictify-hybrid/src/circuit_breaker_tests.rs
  3. Test and commit
    • cargo test -p predictify-hybrid halfopen_quota
    • Cover edge cases
    • Include test output and notes in the PR

Example commit message

feat: add half-open quota scheduler to CircuitBreaker

Acceptance Criteria

  • Half-open admits exactly calls_per_minute calls per evaluation window
  • Transitions deterministically on quota saturation
  • No unwrap() in any new code path

Guidelines

  • Validate auth, overflow, and storage TTL/archival
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GRANTFOX OSSGrantFox open-source campaign taskOFFICIAL CAMPAIGNOfficial GrantFox campaign issueStellar WaveIssues in the Stellar wave programenhancementNew feature or improvementrustRust implementationsmart-contractSoroban smart-contract worksorobanSoroban SDK / Stellar

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions