waitfor

module
v0.0.0-...-6e8e918 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: Apache-2.0

README

waitfor

Go Report Card GoDoc

WaitFor is a simple library for implementing dependency checks in your Go application.

Summary

Waitfor provides a simple API to wait for your applications dependancies to become available. For example if your application relies on an external database wait for can check that the service is up and listening. This can be useful in container environments where your services DNS name is not registered until the remote service becomes healthy.

Usage

See the GoDoc examples for more detail.

  • Install with go get: go get -u github.com/davejohnston/waitfor

  • Create a dependancy handler:

var dependancies = waitfor.NewDependencies()()
  • Add a dependancy:
dependancies.Add("rest-api", waitfor.ServiceListening("0.0.0.0:9999", 10*time.Second))
dependancies.Add("postgres-db", waitfor.DatabaseReady("postgres", "host=localhost port=5423 user=postgres password=secret dbname=postgres sslmode=disable")
  • Wait for the dependancies:
if err := dependancies.Wait(); err != nil {
    log.fatal(err)
}

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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