Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultDataDir() (string, error)
- func DisableUpload(dataDir string) error
- func EnableUpload(dataDir string) error
- func InitializeDataDir() (string, error)
- func StatePath(dataDir, name string) string
- func UploadDisabled(dataDir string) bool
- func UsageDBPath(dataDir string) string
- type DataLock
- type FileStore
Constants ¶
const DisabledFile = "upload-disabled"
DisabledFile is the sentinel whose existence suspends uploads. The file's existence is the whole record: there is nothing inside it to parse, so there is no such thing as a corrupt or half-written switch, and a user can flip it with touch and rm when no CLI is handy.
const LockFile = "tokitoki.lock"
const (
UsageDBFile = "tokitoki.db"
)
Variables ¶
var ErrLockBusy = errors.New("another Tokitoki command is still running")
ErrLockBusy reports that another process held the lock for the whole timeout. Callers that treat "someone else is already doing this work" as success test for it with errors.Is.
Functions ¶
func DefaultDataDir ¶
func DisableUpload ¶ added in v0.1.7
DisableUpload creates the sentinel. Calling it on an already-disabled install succeeds and changes nothing.
func EnableUpload ¶ added in v0.1.7
EnableUpload removes the sentinel. A missing file is success: the caller asked for uploads to be on, and they are.
func InitializeDataDir ¶
func StatePath ¶ added in v0.1.7
StatePath returns the path of a state file within the data directory.
func UploadDisabled ¶ added in v0.1.7
UploadDisabled reports whether uploads are suspended.
A stat error other than "does not exist" counts as disabled: a state directory we cannot read is not one to upload from, and refusing to send is always recoverable while sending is not.
func UsageDBPath ¶ added in v0.1.3
UsageDBPath returns the path to the usage database file within the data directory.
Types ¶
type DataLock ¶
type DataLock struct {
// contains filtered or unexported fields
}
func AcquireLock ¶
AcquireLock takes an exclusive advisory lock on dir/state/name, waiting up to timeout before giving up with ErrLockBusy.
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
func (*FileStore) EnsureAPIKeyFile ¶
func (*FileStore) LoadSettings ¶
LoadSettings reads the API key from the config/api_key file.