Skip to content

Feature: Go-Native Backpressure Signaling (Channel Emits) #46

@cinar

Description

@cinar

Description: Idiomatic Go applications heavily utilize channels. Instead of an upstream system (like a Kafka consumer) pulling a message, trying to process it, and getting a "Circuit Open" error, the resilience policy should broadcast its health state proactively so the upstream can pause itself.

  • Architecture & Implementation Requirements:

    • API Design: Add a Health() <-chan StateEvent method to the main Policy and CircuitBreaker interfaces.
    • Event Emission: Whenever the underlying system degrades (e.g., Adaptive Limiter drops capacity by 50%, or Circuit Breaker shifts to Open), emit an event to the channel.
    • Non-Blocking: The channel send must be non-blocking (select { case ch <- event: default: }) so that a slow reader does not lock up the execution loop.
  • Acceptance Criteria:

    • Provide an example (examples/backpressure/main.go) showing how a worker pool can select on this health channel to dynamically pause and resume processing based on downstream health.
    • No goroutine leaks; the channel management must cleanly tear down if the parent context is cancelled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions