Documentation ¶
Index ¶
- Constants
- Variables
- func AlignDuration(tm time.Time, interval time.Duration) time.Duration
- func AlignTime(tm time.Time, interval time.Duration) time.Time
- func AuthHandler(username, password string, onError ErrorFunc) func(h http.Handler) http.Handler
- func CloseIdleConnections(c *http.Client)
- func CombinedOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error)
- func CompressWithGzip(data io.Reader) (io.Reader, error)
- func ExitStatus(err error) (int, bool)
- func ParseTimestamp(timestamp interface{}, format string) (time.Time, error)
- func ParseTimestampWithLocation(timestamp interface{}, format string, location string) (time.Time, error)
- func ProductToken() string
- func RandomDuration(max time.Duration) time.Duration
- func RandomSleep(max time.Duration, shutdown chan struct{})
- func RandomString(n int) string
- func ReadLines(filename string) ([]string, error)
- func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error)
- func RunTimeout(c *exec.Cmd, timeout time.Duration) error
- func SetVersion(v string) error
- func SleepContext(ctx context.Context, duration time.Duration) error
- func SnakeCase(in string) string
- func Version() string
- func WaitTimeout(c *exec.Cmd, timeout time.Duration) error
- type ContentDecoder
- type ContentEncoder
- type Duration
- type ErrorFunc
- type GzipDecoder
- type GzipEncoder
- type IdentityDecoder
- type IdentityEncoder
- type Number
- type Size
Constants ¶
const Usage = `` /* 2532-byte string literal not displayed */
Variables ¶
Functions ¶
func AlignDuration ¶
AlignDuration returns the duration until next aligned interval. If the current time is aligned a 0 duration is returned.
func AlignTime ¶
AlignTime returns the time of the next aligned interval. If the current time is aligned the current time is returned.
func AuthHandler ¶
AuthHandler returns a http handler that requires HTTP basic auth credentials to match the given username and password.
func CloseIdleConnections ¶
func CombinedOutputTimeout ¶
CombinedOutputTimeout runs the given command with the given timeout and returns the combined output of stdout and stderr. If the command times out, it attempts to kill the process.
func CompressWithGzip ¶
CompressWithGzip takes an io.Reader as input and pipes it through a gzip.Writer returning an io.Reader containing the gzipped data. An error is returned if passing data to the gzip.Writer fails
func ExitStatus ¶
Exit status takes the error from exec.Command and returns the exit status and true if error is not exit status, will return 0 and false
func ParseTimestamp ¶
ParseTimestamp with no location provided parses a timestamp value as UTC
func ParseTimestampWithLocation ¶
func ParseTimestampWithLocation(timestamp interface{}, format string, location string) (time.Time, error)
ParseTimestamp parses a timestamp value as a unix epoch of various precision.
format = "unix": epoch is assumed to be in seconds and can come as number or string. Can have a decimal part. format = "unix_ms": epoch is assumed to be in milliseconds and can come as number or string. Cannot have a decimal part. format = "unix_us": epoch is assumed to be in microseconds and can come as number or string. Cannot have a decimal part. format = "unix_ns": epoch is assumed to be in nanoseconds and can come as number or string. Cannot have a decimal part.
func ProductToken ¶
func ProductToken() string
ProductToken returns a tag for Telegraf that can be used in user agents.
func RandomDuration ¶
RandomDuration returns a random duration between 0 and max.
func RandomSleep ¶
RandomSleep will sleep for a random amount of time up to max. If the shutdown channel is closed, it will return before it has finished sleeping.
func RandomString ¶
RandomString returns a random string of alpha-numeric characters
func ReadLines ¶
ReadLines reads contents from a file and splits them by new lines. A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).
func ReadLinesOffsetN ¶
ReadLines reads contents from file and splits them by new line. The offset tells at which line number to start. The count determines the number of lines to read (starting from offset):
n >= 0: at most n lines n < 0: whole file
func RunTimeout ¶
RunTimeout runs the given command with the given timeout. If the command times out, it attempts to kill the process.
func SleepContext ¶
SleepContext sleeps until the context is closed or the duration is reached.
Types ¶
type ContentDecoder ¶
ContentDecoder removes a wrapper encoding from byte buffers.
func NewContentDecoder ¶
func NewContentDecoder(encoding string) (ContentDecoder, error)
NewContentDecoder returns a ContentDecoder for the encoding type.
type ContentEncoder ¶
ContentEncoder applies a wrapper encoding to byte buffers.
func NewContentEncoder ¶
func NewContentEncoder(encoding string) (ContentEncoder, error)
NewContentEncoder returns a ContentEncoder for the encoding type.
type Duration ¶
Duration just wraps time.Duration
func (*Duration) UnmarshalTOML ¶
UnmarshalTOML parses the duration from the TOML config file
type ErrorFunc ¶
type ErrorFunc func(rw http.ResponseWriter, code int)
ErrorFunc is a callback for writing an error response.
type GzipDecoder ¶
type GzipDecoder struct {
// contains filtered or unexported fields
}
GzipDecoder decompresses buffers with gzip compression.
func NewGzipDecoder ¶
func NewGzipDecoder() (*GzipDecoder, error)
type GzipEncoder ¶
type GzipEncoder struct {
// contains filtered or unexported fields
}
GzipEncoder compresses the buffer using gzip at the default level.
func NewGzipEncoder ¶
func NewGzipEncoder() (*GzipEncoder, error)
type IdentityDecoder ¶
type IdentityDecoder struct{}
IdentityDecoder is a null decoder that returns the input.
func NewIdentityDecoder ¶
func NewIdentityDecoder() *IdentityDecoder
type IdentityEncoder ¶
type IdentityEncoder struct{}
IdentityEncoder is a null encoder that applies no transformation.
func NewIdentityEncoder ¶
func NewIdentityEncoder() *IdentityEncoder