waitfor

package module
v0.0.0-...-e096be6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

README

Build Status Coverage Status

waitfor

Command-line tool and Go library to wait for various conditions to become true. Inspired by Ansible's wait_for module. It currently supports port checks. More checks will be added in the future, e.g. checks for files, processes.

Installation

Make sure Go is installed and setup correctly. To pull the library into the $GOPATH directory, build the binary, and put it into the $GOBIN directory, simply run:

go get github.com/st3v/waitfor/...

Assuming your $PATH contains $GOBIN, you can now run waitfor from anywhere on your machine.

waitfor --help

Command-line Interface

Wait for Host to Listen on Port
$ waitfor port --help
NAME:
   waitfor port - wait for host to listen on port

USAGE:
   waitfor port [command options] [arguments...]

OPTIONS:
   --closed, -c			wait for port to be closed
   --host, -h "127.0.0.1"	resolvable hostname or IP address
   --network, -n "tcp"		named network, ['tcp', 'tcp4', 'tcp6', 'udp', 'udp4', 'udp6', 'ip', 'ip4', 'ip6']
   --timeout, -t "5m0s"		maximum time to wait for
   --interval, -i "1s"		time in-between checks
   --verbose, -v		enable additional logging

For example, wait up to 1 minute for localhost to listen on port 8080 using the tcp protocol. Check port every 500 milliseconds.

waitfor port 8080 -h localhost -n tcp -t 1m -i 500ms
Wait for Host to Stop Listening on Port

Use the --closed flag to wait for a port to be closed.

waitfor port 8080 -h localhost -n tcp -c

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeoutExceeded = errors.New("timeout exceeded")

Functions

func Condition

func Condition(condition Check, interval time.Duration, errChan chan error, ctx context.Context)

func ConditionWithTimeout

func ConditionWithTimeout(condition Check, interval, timeout time.Duration) error

Types

type Check

type Check func() bool

Directories

Path Synopsis
cmd
waitfor/fake
This file was generated by counterfeiter
This file was generated by counterfeiter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL