Documentation
¶
Overview ¶
Package runlock is the single-instance lock of a machine's runtime: an exclusive flock on a guard file in the data folder, held for as long as the process lives, so the kernel drops it when the process dies however it dies. Beside it lies the file naming the holder and its port: it is what a newcomer's refusal quotes, and what a runtime older than the guard is recognised by (that one is asked on its port's health route, as it asked itself).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
File string
// App is the name a runtime's health route answers with ("app").
App string
// Health asks a port's health route for its app name; nil asks http://127.0.0.1:<port>/api/health.
Health func(port int) (string, bool)
Now func() time.Time
}
Config says where the lock is and how a holder is recognised.
type HeldError ¶
type HeldError struct{ PID, Port int }
HeldError: a live runtime holds the lock. PID and Port are zero when the holder has not named itself yet.
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock is a lock this process holds.
func Acquire ¶
Acquire takes the lock for this process on port. While another process holds the guard it is a *HeldError, whether or not that process answers on its port. With the guard taken, the holder file is only a leftover: of a process that is gone, or of a runtime older than the guard, which is a *HeldError while it answers on its port.