From d592bb931eb861a1acd239854e80bbf71ece8a7a Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 4 Mar 2025 14:49:07 +0300 Subject: [PATCH] [#339] pool/tree: Configure circuit breaker parameters Signed-off-by: Alex Vanin --- pool/tree/pool.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pool/tree/pool.go b/pool/tree/pool.go index 7b1afef..f5cee26 100644 --- a/pool/tree/pool.go +++ b/pool/tree/pool.go @@ -376,6 +376,18 @@ func (x *InitParameters) SetNetMapInfoSource(netMapInfoSource NetMapInfoSource) x.netMapInfoSource = netMapInfoSource } +// SetCircuitBreakerThreshold sets number of consecutive failed connection before +// circuit is considered closed and therefore return error immediately. +func (x *InitParameters) SetCircuitBreakerThreshold(circuitBreakerThreshold int) { + x.circuitBreakerThreshold = circuitBreakerThreshold +} + +// SetCircuitBreakerDuration sets duration for circuit to be considered closed. +// This effectively limits to one new connection try per duration. +func (x *InitParameters) SetCircuitBreakerDuration(circuitBreakerDuration time.Duration) { + x.circuitBreakerDuration = circuitBreakerDuration +} + // GetNodes invokes eponymous method from TreeServiceClient. // // Can return predefined errors: