Documentation
¶
Index ¶
- func CreateViaTempMove(path, tempDir, prefix string, fn func(w io.Writer) error) error
- func ForEachFile(path string, fn func(os.FileInfo) error) error
- func LoopUntil(c context.Context, p time.Duration, fn func(context.Context) error) error
- func Sleep(c context.Context, d time.Duration) error
- type Application
- type Hex
- type Sleeper
- type StringSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateViaTempMove ¶
CreateViaTempMove atomically writes a file containing content to path.
In order to do this atomically, we first create the file in a temporary directory and, upon success, move it into place via an atomic move.
On failure, cleanup is best-effort.
func ForEachFile ¶
ForEachFile iterates over every file in the specified directory path, invoking fn for each identified file.
If path is not a directory, ForEachFile will return an error.
If fn returns an error, iteration will stop and ForEachFile will return that error.
func LoopUntil ¶
LoopUntil runs the function fn periodically, every p, until the Context is cancelled or the function returns an error. fn will run immediately, and then periodicalkly after that.
If fn returns an error, LoopUntil will terminate immediately and return that error. Otherwise, LoopUntil will return the Context's cancellation error.
Types ¶
type Application ¶
type Application struct { // Verbosity is the logging verbosity level. Verbosity zapcore.Level // Production, if true, means to run in production logging mode. Production bool // ColorizeLogs, if true, allows the application to colorize its logs. ColorizeLogs bool // LogPath, if not nil, is a path to output logs to. LogPath string // Profiler is the configured profiler to use. Profiler profiling.Profiler }
Application is a configuration for a generic application entry point.
Application will set up a basic Context, signal handler, and run an execute method.
func (*Application) AddFlags ¶
func (a *Application) AddFlags(fs *pflag.FlagSet)
AddFlags adds application-level flags to fs.
type Hex ¶
type Hex []byte
Hex is a byte slice that encodes as a hex-dumped string.
It can be used for easy lazy hex dumping.
type Sleeper ¶
type Sleeper struct {
// contains filtered or unexported fields
}
Sleeper is a device that facilitates Context-cancellable sleeping.
Sleeper is not safe for concurrent usage.
func (*Sleeper) Close ¶
func (s *Sleeper) Close()
Close closes the Sleeper, releasing any resources that it owns.
Close is optional, but may offer better resource management if called.
type StringSlice ¶
StringSlice lazily renders to a Delim-delimited string.
func (*StringSlice) String ¶
func (ss *StringSlice) String() string