Rust

Stores that share a breaker's verdict between processes: Adapter, with Table (an in-process table) and Redis.

Contents

use utopia_circuit_breaker::SharedTable;
Rust
pub struct SharedTable

A table of rows shared by every Table adapter made on it: one per process (or per worker group) where Swoole would share memory.

Also implements Default.
use utopia_circuit_breaker::Table;
Rust
pub struct Table

Shares breaker state through a SharedTable in this process, under a key prefix (breaker: by default). Keys longer than 63 bytes are hashed to fit.

Rust
use utopia_circuit_breaker::{Adapter, SharedTable, Stored, Table};

let table = SharedTable::new(32, 255);
let first = Table::new(table.clone(), "test:");
let second = Table::new(table, "test:");

first.set("failures", Stored::Int(2)).await?;
assert_eq!(second.increment("failures", 1).await?, 3);
use utopia_circuit_breaker::Stored;
Rust
pub enum Stored

A value in a store: a string or an integer.

Also implements From.
use utopia_circuit_breaker::Adapter;
Rust
pub trait Adapter: Send + Sync

Where breakers keep the state they share: a key-value store with increments. Implement it to share state another way.

Implemented byArcTable