Skip to content

Conversation

@zhoushuguang
Copy link
Collaborator

feat(zrpc): instance breaker support

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

feat(zrpc): instance breaker support

feat(zrpc): instance breaker support
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements instance-level circuit breaker support for the zRPC framework. The change moves circuit breaker logic from the interceptor layer (which operates at the service level) to the balancer layer (which operates at the instance level), enabling more granular failure isolation and automatic retry to healthy instances when a specific instance's breaker opens.

Changes:

  • Introduced a new zrpc/internal/balancer/breaker package that wraps balancer pickers with per-instance circuit breaker logic
  • Simplified the BreakerInterceptor to only enable the breaker context flag instead of executing the breaker logic
  • Integrated the breaker wrapper into both p2c and consistenthash load balancers with configurable retry behavior

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
zrpc/internal/balancer/breaker/breaker.go New core implementation providing breakerPicker that wraps any balancer picker with per-instance circuit breaking
zrpc/internal/balancer/breaker/breaker_test.go Comprehensive test suite covering all breaker picker scenarios including retry logic and error handling
zrpc/internal/clientinterceptors/breakerinterceptor.go Simplified to just set breaker context flag via WithBreaker() instead of executing breaker logic
zrpc/internal/clientinterceptors/breakerinterceptor_test.go Updated to verify breaker flag is set in context; removed old service-level breaker tests
zrpc/internal/balancer/p2c/p2c.go Integrated breaker wrapper with retryable=true for p2c load balancing
zrpc/internal/balancer/p2c/p2c_test.go Updated to unwrap breaker picker when accessing internal p2cPicker
zrpc/internal/balancer/consistenthash/consistenthash.go Integrated breaker wrapper with retryable=false for consistent hash balancing
zrpc/internal/balancer/consistenthash/consistenthash_test.go Updated to unwrap breaker picker when accessing internal picker
zrpc/client.go Exposed WrapPicker as public API for custom load balancer integration
zrpc/client_test.go Added test for WrapPicker public API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant