CircuitBreaker


Object Hierarchy:

Object hierarchy for CircuitBreaker

Description:

public class CircuitBreaker : Object

Circuit breaker for protecting unstable dependencies.

CircuitBreaker guards expensive or unreliable calls and prevents cascading failures. After enough failures, it opens and rejects calls immediately until timeout elapses.

Example:

    var created = CircuitBreaker.of ("payments");
if (created.isError ()) {
return;
}
var breaker = created.unwrap ();

var configured = breaker.withFailureThreshold (3);
if (configured.isError ()) {
return;
}
configured = breaker.withOpenTimeout (Duration.ofSeconds (10));
if (configured.isError ()) {
return;
}

Result<string, string> result = breaker.call<string> (() => {
string? payload = fetch_from_remote ();
if (payload == null) {
return Result.error<string, string> ("remote returned empty payload");
}
return Result.ok<string, string> (payload);
});


Namespace: Vala.Net
Package: Valacore

Content:

Static methods:

Methods:

Inherited Members:

All known members inherited from class GLib.Object