Documentation
¶
Index ¶
- Variables
- func BackoffWaitFor(pred func() bool, cap time.Duration, timeout time.Duration) error
- func FileExists(path string) (bool, error)
- func GetNodeBinary() (string, error)
- func JoinNotifiers(notifiers ...chan struct{}) chan struct{}
- func Mkdir(path string, perm os.FileMode) error
- func MyIP() (string, error)
- func Open(path string) (afero.File, error)
- func PrintUsageString(commands string, explanation string, flags *flag.FlagSet)
- func ReadFile(filename string) (string, error)
- func RemoveAll(path string) error
- func ShortUUID(uuid string) string
- func Stat(path string) (os.FileInfo, error)
- func ToTar(name string, permissions int, content string) (io.Reader, error)
- func Walk(root string, walkFn filepath.WalkFunc) error
- func WriteFile(filename string, data []byte, perm os.FileMode) error
- type EventTimer
- type Formatter
Constants ¶
This section is empty.
Variables ¶
After returns whether the current time is after t. It is stored in a variable so it can be mocked out for unit tests.
var AppFs = afero.NewOsFs()
AppFs is an aero filesystem. It is stored in a variable so that we can replace it with in-memory filesystems for unit tests.
var Sleep = time.Sleep
Sleep stores time.Sleep so we can mock it out for unit tests.
Functions ¶
func BackoffWaitFor ¶
BackoffWaitFor waits until `pred` is satisfied, or `timeout` Duration has passed. Every time the predicate fails, double the sleep interval until `cap` is reached.
func FileExists ¶
FileExists checks if the given path corresponds to an existing file in the Afero file system.
func GetNodeBinary ¶
GetNodeBinary returns the name of the Node.js binary. Even though `node` is the blessed name for the Node.js binary, some package managers (e.g. apt-get) install the binary as `nodejs`. The `nodejs` name is used by package managers that already had a package named `node`, so to avoid accidentally executing the wrong `node` binary, we try the `nodejs` binary first.
func JoinNotifiers ¶
func JoinNotifiers(notifiers ...chan struct{}) chan struct{}
JoinNotifiers merges a list of notifications channels. The returned channel will notify if one or more notifications have occurred on any of the channels since the last time it was checked.
func MyIP ¶
MyIP gets the local systems Public IP address as visible on the WAN by querying an external service.
func PrintUsageString ¶
PrintUsageString formats and prints usage strings for cli commands.
Types ¶
type EventTimer ¶
type EventTimer struct {
// contains filtered or unexported fields
}
EventTimer is a utility struct that allows us to time how long loops take, as well as how often they are triggered.
func NewEventTimer ¶
func NewEventTimer(eventName string) *EventTimer
NewEventTimer creates and returns a ready to use EventTimer
func (*EventTimer) LogEnd ¶
func (ltl *EventTimer) LogEnd()
LogEnd logs the end of a loop and how long it took to run.
func (*EventTimer) LogStart ¶
func (ltl *EventTimer) LogStart()
LogStart logs the start of a loop and how long it has been since the last trigger.