Skip to content

A lightweight Rust utility to wait for one or multiple services to be available.

License

Notifications You must be signed in to change notification settings

PanGan21/wait-for-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wait-for-rs

A versatile Rust library and command-line tool for waiting on network resources to become available. It can be seamlessly integrated into Rust projects as a library or used as a standalone command-line utility. Additionally, it can be easily incorporated into Dockerfiles for containerized environments.

Features

  • Flexible: It can be used as both a library and a command-line tool, offering flexibility in integration and usage.
  • Easy Installation: The command-line tool can be installed globally and used directly in shell scripts or Dockerfiles.
  • Network Resource Waiting: Use wait-for-rs to wait for network resources such as URLs and TCP sockets to become available.
  • Customizable: Configure wait durations, timeouts, and intervals according to your specific requirements.

Installation

To install wait-for-rs as a command-line tool, simply run:

cd wait-for-rs && cargo install --path .

Library

To use wait-for-rs as a library in your Rust project, add the following to your Cargo.toml:

[dependencies]
wait-for-rs = { git = "https://github.com/PanGan21/wait-for-rs.git", branch = "main" }

Usage

Command-Line Tool

To start the server:

# Wait for a TCP socket to become available
wait-for-rs 127.0.0.1:8080 --timeout 60

Library

use wait_for_rs::{WaitService, Result};

fn main() -> Result<()> {
    // Create a WaitService instance and wait for services
    let wait_service = WaitService::new(vec!["google.com:443".to_string()], 30)?;
    wait_service.wait_for_services()?;
    Ok(())
}

For more detailed usage instructions and API documentation, please refer to the examples.

Run the tests
cargo test

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A lightweight Rust utility to wait for one or multiple services to be available.

Topics

Resources

License

Stars

Watchers

Forks

Languages