store

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
const LockFile = "tokitoki.lock"
View Source
const (
	UsageDBFile = "tokitoki.db"
)

Variables

View Source
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 DefaultDataDir() (string, error)

func DisableUpload added in v0.1.7

func DisableUpload(dataDir string) error

DisableUpload creates the sentinel. Calling it on an already-disabled install succeeds and changes nothing.

func EnableUpload added in v0.1.7

func EnableUpload(dataDir string) error

EnableUpload removes the sentinel. A missing file is success: the caller asked for uploads to be on, and they are.

func InitializeDataDir

func InitializeDataDir() (string, error)

func StatePath added in v0.1.7

func StatePath(dataDir, name string) string

StatePath returns the path of a state file within the data directory.

func UploadDisabled added in v0.1.7

func UploadDisabled(dataDir string) bool

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

func UsageDBPath(dataDir string) string

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 AcquireDataLock

func AcquireDataLock(dir string, timeout time.Duration) (*DataLock, error)

func AcquireLock

func AcquireLock(dir, name string, timeout time.Duration) (*DataLock, error)

AcquireLock takes an exclusive advisory lock on dir/state/name, waiting up to timeout before giving up with ErrLockBusy.

func (*DataLock) Close

func (l *DataLock) Close() error

type FileStore

type FileStore struct {
	// contains filtered or unexported fields
}

func Open

func Open(dir string) (*FileStore, error)

func (*FileStore) EnsureAPIKeyFile

func (s *FileStore) EnsureAPIKeyFile() error

func (*FileStore) LoadSettings

func (s *FileStore) LoadSettings() (agent.Settings, error)

LoadSettings reads the API key from the config/api_key file.

func (*FileStore) SaveAPIKey

func (s *FileStore) SaveAPIKey(apiKey string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL