7 releases

0.1.6 Mar 20, 2021
0.1.5 Mar 17, 2021

#2608 in Database interfaces

Download history 1593/week @ 2024-11-16 1804/week @ 2024-11-23 2659/week @ 2024-11-30 2292/week @ 2024-12-07 1804/week @ 2024-12-14 425/week @ 2024-12-21 734/week @ 2024-12-28 1913/week @ 2025-01-04 2514/week @ 2025-01-11 2111/week @ 2025-01-18 3007/week @ 2025-01-25 2890/week @ 2025-02-01 3008/week @ 2025-02-08 3620/week @ 2025-02-15 4116/week @ 2025-02-22 2994/week @ 2025-03-01

14,213 downloads per month

MIT license

29KB
391 lines

Toxiproxy - Rust client

Build Status Crates.io

Rust client for Toxiproxy.

Usage

Populating proxies:

let proxies = TOXIPROXY.populate(vec![
  Proxy::new(
    "socket_service".into(),
    "localhost:2001".into(),
    "localhost:2000".into(),
  ),
  Proxy::new(
    "redis".into(),
    "localhost:6000".into(),
    "localhost:6379".into(),
  )
])?;

Testing with an unavailable connection:

TOXIPROXY.find_and_reset_proxy("redis")?.with_down(|| {
  // Calling the desired service...
})?;

Testing with toxics (for full documentation on available toxics see the original docs):

TOXIPROXY.find_and_reset_proxy("redis")?.with_latency("downstream".into(), 2000, 0, 1.0).apply(|| {
  // Calling the desired service...
})?;

Or without a safe lambda (that takes care of resetting a proxy):

TOXIPROXY.find_proxy("redis")?.with_latency("downstream".into(), 2000, 0, 1.0)
// Calling the desired service...

TOXIPROXY.find_proxy("redis")?.disable();
// Test unavailability.
TOXIPROXY.find_proxy("redis")?.enable();

Supported toxics:

Using a custom address for Toxiproxy server:

let toxiclient: Client = toxiproxy_rust::Client::new("1.2.3.4:5678");

Development

Tests:

$> cargo test -- --test-threads 1

Dependencies

~4–16MB
~222K SLoC