Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Check ¶
type Check func() error
Check is function that determines if a dependency is available it returns an error if the dependency is not ready.
func DatabaseReady ¶
DatabaseReady determines if a database can be connected to. It takes a driver such as mysql or postgres-db and a datasource string. e.g. to connect to a postgres database call the method with these parameters DatabaseReady("postgres", "host=localhost port=5432 user=postgres password=secret dbname=postgres sslmode=disable")
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is a dependency Handler. It maintains a list of dependencies to check
func NewDependencies ¶
func NewDependencies() *Handler
NewDependencies returns a dependancy handler. This can be used to add multiple dependencies for an application. Calling wait on the handler will cause the handler to wait until all dependencies are ready, or until it timesout.
Example ¶
package main
import (
"log"
"time"
"github.com/davejohnston/waitfor/pkg/waitfor"
)
func main() {
dependencies := waitfor.NewDependencies()
dependencies.Add("rest-api", waitfor.ServiceListening("0.0.0.0:9999", 10*time.Second))
err := dependencies.Wait()
if err != nil {
log.Fatal(err)
}
}
Output: