https://github.com/trekawek/toxiproxy-java
Java API client for the Toxiproxy
https://github.com/trekawek/toxiproxy-java
Last synced: 9 months ago
JSON representation
Java API client for the Toxiproxy
- Host: GitHub
- URL: https://github.com/trekawek/toxiproxy-java
- Owner: trekawek
- License: other
- Created: 2016-02-19T13:42:09.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-03-02T14:46:38.000Z (almost 2 years ago)
- Last Synced: 2025-04-02T12:08:16.130Z (9 months ago)
- Language: Java
- Size: 165 KB
- Stars: 115
- Watchers: 5
- Forks: 17
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-java - Toxiproxy Java
README
# toxiproxy-java
[](https://github.com/trekawek/toxiproxy-java/actions?query=workflow%3ACI)
This is a client library for the [Toxiproxy](https://github.com/shopify/toxiproxy) - a proxy that simulates network and system conditions. With toxiproxy-java you may use a convenient Java API to create and manage proxies. Before you using this library, please read the [Usage section of the Toxiproxy README](https://github.com/shopify/toxiproxy#usage).
Installation:
```xml
eu.rekawek.toxiproxy
toxiproxy-java
2.1.7
```
## Usage
By default, the `ToxiproxyClient` tries to connect to the `http://localhost:8474`. This might be changed using the parametrized constructor:
```java
ToxiproxyClient client = new ToxiproxyClient("192.168.1.1", 8474);
```
Following snippet will create a new proxy for the MySQL service:
```java
Proxy mysqlProxy = client.createProxy("mysql", "localhost:21212", "localhost:3306");
```
The proxy will listen on port 21212 on the loopback interface and transfer all the traffic to port 3306. We may also create a [toxic](https://github.com/shopify/toxiproxy#toxics):
```java
mysqlProxy.toxics().latency("my-latency-toxic", DOWNSTREAM, 100).setJitter(15);
```
For a full list of toxics, please visit the [Toxiproxy README](https://github.com/shopify/toxiproxy#toxics).