heartbeat 0.0.1

A high-performance heartbeat client.
Documentation
  • Coverage
  • 0%
    0 out of 13 items documented0 out of 6 items with examples
  • Size
  • Source code size: 6.85 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 560.57 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 22s Average build duration of successful builds.
  • all releases: 22s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ghost_1457

heartbeat.rs

Overview

A high-performance heartbeat client to check pulse of TCP servers. It utilizes TCP's connection handshake mechanism without even sending a client payload so it doesn't flood a network with client payloads.

##Example:

extern crate heartbeat;

use std::net::SocketAddr;
use heartbeat::PulseResult;

// a handler to handle the result of a heartbeat pulse
fn do_nothing(res: PulseResult) {
  match res {
      Ok(addr) => println!("found pulse for {:?}", addr),
      Err(addr) => println!("no pulse for {:?}", addr)
  }
}

fn main() {
  let servers: Vec<SocketAddr> = ...;
  let freq_ms: u32 = 5 * 1000;
  let client = heartbeat::load(servers, do_nothing, freq_ms).unwrap();
  client.start();
}

It is designed to be simple and efficient to embed into your own application.

Configuration

The TCP servers that you wish to check pulses of are added by specifying them in a TOML configuration file like this:

# Heartbeat.toml
[configuration]
servers = ["127.0.0.1:8080", "127.0.0.1:6767"]
frequency = 5000