Skip to content

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

License

Notifications You must be signed in to change notification settings

davejohnston/waitfor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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)
}

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages