7个版本

0.1.6 2021年3月20日
0.1.5 2021年3月17日

#2584 in 数据库接口

Download history · Rust 包仓库 315/week @ 2024-03-14 · Rust 包仓库 635/week @ 2024-03-21 · Rust 包仓库 630/week @ 2024-03-28 · Rust 包仓库 576/week @ 2024-04-04 · Rust 包仓库 485/week @ 2024-04-11 · Rust 包仓库 705/week @ 2024-04-18 · Rust 包仓库 632/week @ 2024-04-25 · Rust 包仓库 800/week @ 2024-05-02 · Rust 包仓库 635/week @ 2024-05-09 · Rust 包仓库 895/week @ 2024-05-16 · Rust 包仓库 634/week @ 2024-05-23 · Rust 包仓库 1012/week @ 2024-05-30 · Rust 包仓库 967/week @ 2024-06-06 · Rust 包仓库 1327/week @ 2024-06-13 · Rust 包仓库 1438/week @ 2024-06-20 · Rust 包仓库 805/week @ 2024-06-27 · Rust 包仓库

每月4,670次下载

MIT许可证

29KB
391

毒proxy - Rust客户端

Build Status Crates.io

Rust客户端,用于Toxiproxy

用法

填充代理

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(),
  )
])?;

测试不可用连接

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

使用毒药(有关可用毒药的完整文档,请参阅原始文档

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

或没有安全的lambda(负责重置代理)

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();

支持的毒药

为Toxiproxy服务器使用自定义地址

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

开发

测试

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

依赖关系

~4–19MB
~245K SLoC