Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultExecHandler(result sql.Result) (bool, error)
- func DefaultQueryHandler(rows *sql.Rows) (bool, error)
- type HTTP
- type HTTPConfig
- type ReachableChecker
- type ReachableConfig
- type ReachableDatadogIncrementer
- type ReachableDialer
- type SQL
- type SQLConfig
- type SQLExecer
- type SQLExecerResultHandler
- type SQLPinger
- type SQLQueryer
- type SQLQueryerResultHandler
Constants ¶
const ( // ReachableDDHealthErrors is the datadog name used when there is a failure in the reachable checker ReachableDDHealthErrors = "health.errors" // ReachableDefaultPort is the default port used if no port is defined in a reachable checker ReachableDefaultPort = "80" // ReachableDefaultNetwork is the default network used in the reachable checker ReachableDefaultNetwork = "tcp" )
Variables ¶
var ( // ReachableDefaultTimeout is the default timeout used when reachable is checking the URL ReachableDefaultTimeout = time.Duration(3) * time.Second )
Functions ¶
func DefaultExecHandler ¶
DefaultExecHandler is the default SQLExecer result handler that assumes one row was affected in the passed query
Types ¶
type HTTP ¶
type HTTP struct {
Config *HTTPConfig
}
HTTP implements the "ICheckable" interface.
func NewHTTP ¶
func NewHTTP(cfg *HTTPConfig) (*HTTP, error)
NewHTTP creates a new HTTP checker that can be used for ".AddCheck(s)".
type HTTPConfig ¶
type HTTPConfig struct { URL *url.URL // Required Method string // Optional (default GET) Payload interface{} // Optional StatusCode int // Optional (default 200) Expect string // Optional Client *http.Client // Optional Timeout time.Duration // Optional (default 3s) }
HTTPConfig is used for configuring an HTTP check. The only required field is `URL`.
"Method" is optional and defaults to `GET` if undefined.
"Payload" is optional and can accept `string`, `[]byte` or will attempt to marshal the input to JSON for use w/ `bytes.NewReader()`.
"StatusCode" is optional and defaults to `200`.
"Expect" is optional; if defined, operates as a basic "body should contain <string>".
"Client" is optional; if undefined, a new client will be created using "Timeout".
"Timeout" is optional and defaults to "3s".
type ReachableChecker ¶
type ReachableChecker struct {
// contains filtered or unexported fields
}
ReachableChecker checks that URL responds to a TCP request
func NewReachableChecker ¶
func NewReachableChecker(cfg *ReachableConfig) (*ReachableChecker, error)
NewReachableChecker creates a new reachable health checker
func (*ReachableChecker) Status ¶
func (r *ReachableChecker) Status() (interface{}, error)
Status checks if the endpoint is reachable
type ReachableConfig ¶
type ReachableConfig struct { URL *url.URL // Required Dialer ReachableDialer // Optional (default net.DialTimeout) Timeout time.Duration // Optional (default 3s) Network string // Optional (default tcp) DatadogClient ReachableDatadogIncrementer // Optional DatadogTags []string // Optional }
ReachableConfig is used for configuring an HTTP check. The only required field is `URL`.
"Dialer" is optional and defaults to using net.DialTimeout.
"Timeout" is optional and defaults to "3s".
"Network" is optional and defaults to "tcp"; it should be one of "tcp", "tcp4", "tcp6", "unix", "unixpacket", "udp", "udp4", "udp6", "unixgram" or an IP transport. The IP transports are "ip", "ip4", or "ip6" followed by a colon and a literal protocol number or a protocol name, as in "ip:1" or "ip:icmp".
"DatadogClient" is optional; if defined metrics will be sent via statsd.
"DatadogTags" is optional; defines the tags that are passed to datadog when there is a failure
type ReachableDatadogIncrementer ¶
ReachableDatadogIncrementer is any datadog client that has the Incr method for tracking metrics
type ReachableDialer ¶
ReachableDialer is the signature for a function that checks if an address is reachable
type SQL ¶
type SQL struct {
Config *SQLConfig
}
SQL implements the "ICheckable" interface
type SQLConfig ¶
type SQLConfig struct { // Pinger is the value implementing SQLPinger Pinger SQLPinger // Queryer is the value implementing SQLQueryer Queryer SQLQueryer // Execer is the value implementing SQLExecer Execer SQLExecer // Query is the parameterized SQL query required // with both Queryer and Execer Query string // Params are the SQL query parameters, if any Params []interface{} // QueryerResultHandler handles the result of // the QueryContext function QueryerResultHandler SQLQueryerResultHandler // ExecerResultHandler handles the result of // the ExecContext function ExecerResultHandler SQLExecerResultHandler }
SQLConfig is used for configuring a database check. One of the Pinger, Queryer, or Execer fields is required.
If Execer is set, it will take precedence over Queryer and Pinger, Execer implements the SQLExecer interface in this package. The sql.DB and sql.TX structs both implement this interface.
Note that if the Execer is set, then the ExecerResultHandler and Query values MUST also be set
If Queryer is set, it will take precedence over Pinger. SQLQueryer implements the SQLQueryer interface in this package. The sql.DB and sql.TX structs both implement this interface.
Note that if the Queryer is set, then the QueryerResultHandler and Query values MUST also be set
Pinger implements the SQLPinger interface in this package. The sql.DB struct implements this interface.
type SQLExecer ¶
type SQLExecer interface {
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}
SQLExecer is an interface that allows executing of queries in the database
type SQLExecerResultHandler ¶
SQLExecerResultHandler is the BYO function to handle a database exec result