Documentation
¶
Overview ¶
Package ping sends pings to a heartbeat monitor through the Ping API, a POST to the monitor's ping URL or to /start, /fail or /<exit-code> after it. The token in the URL is the only credential, so messages show the URL through Masked or MaskURL.
Index ¶
Constants ¶
const ( // BodyMaxBytes is how much of a ping's body the Ping API keeps. BodyMaxBytes = 10 * 1024 DefaultTimeout = 30 * time.Second )
Variables ¶
var ( // ErrNotPingURL means the URL is not the origin followed by a token, such // as one copied with /start on the end. ErrNotPingURL = errors.New("not a ping URL") // ErrInsecure means plain http to a host other than this machine. ErrInsecure = errors.New("ping URL must use https") // ErrMaskedToken means the URL ends in a mask instead of the token, either // the API's **** for a key without monitors:write or the CLI's own. ErrMaskedToken = errors.New("ping URL token is masked") )
Functions ¶
func FormatSize ¶
FormatSize writes a byte count for people: 102 bytes, 10 KB, 37.1 KB.
func IsNotFound ¶
Types ¶
type Client ¶
type Client struct {
// HTTPClient sends the pings. Its redirect policy is ignored, since a
// redirect could carry the body to another host.
HTTPClient *http.Client
UserAgent string
// Timeout bounds one ping, retries included. Zero is DefaultTimeout.
Timeout time.Duration
// contains filtered or unexported fields
}
type SendError ¶
type SendError struct {
// Status is the last answer's status, or 0 when none came.
Status int
// Err is the last network error when no answer came. Nil means time
// ran out while waiting for one.
Err error
Timeout time.Duration
}
SendError is a ping that got no 2xx answer within its timeout.
type Tail ¶
type Tail struct {
// contains filtered or unexported fields
}
Tail keeps the last bytes written to it. It is safe for concurrent writes, such as a command's stdout and stderr.