json-poller
Data-agnostic JSON polling. Works with any struct that implements Deserialize. Reuses HTTP connections instead of creating new ones each time, eliminating TCP and TLS handshake overhead on every request.
Installation
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
= { = "1.0", = ["derive"] }
Or install directly from GitHub:
[]
= { = "https://github.com/erik404/json-poller" }
= { = "1", = ["full"] }
= { = "1.0", = ["derive"] }
Usage
use JsonPoller;
use Deserialize;
async
Configuration
let poller = builder
.poll_interval_ms // How often to poll (default: 500ms)
.request_timeout_ms // Request timeout (default: 1000ms)
.pool_max_idle_per_host // Connections to keep alive (default: 1)
.pool_idle_timeout_secs // How long to keep connections (default: 90s)
.tcp_keepalive_secs // TCP keepalive interval (default: 60s)
.build?;
Requirements
- Works with any type that implements
serde::Deserialize - Requires
tokioasync runtime - Only supports JSON responses
License
MIT OR Apache-2.0