flagfile

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package flagfile handles the flag files an object keeps in its var directory, where the presence of the file is the flag and its modification time is when the flag was raised.

A flag file is what makes a decision survive a daemon restart or a reboot: the frozen flag says the daemon may not act on the instance, the stopped flag says the daemon may not start it back on its own.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func At

func At(p string) time.Time

At returns the time the flag was raised, or the zero time when it is not.

func Content

func Content(p string) []byte

Content returns the content the flag was raised with, empty when it was raised with none or is not raised.

func Set

func Set(p string) error

Set raises the flag, creating the var directory if needed. Setting a flag already raised leaves its time alone: the flag says when the decision was made, and it was made the first time.

func SetWith

func SetWith(p string, b []byte) error

SetWith raises the flag like Set, with b as the content of the file, which says more about the decision than its time. Setting a flag already raised leaves its content alone too, as the decision it describes.

func Unset

func Unset(p string) error

Unset lowers the flag, and syncs the directory so the removal survives a crash.

Types

type Raised

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

Raised is a flag a call of Raise raised, until it is kept or lowered.

It holds the file it created open, so the file is told apart from one created at the same path after it was removed, which may take its inode when it is free.

func Raise

func Raise(p string) (*Raised, error)

Raise raises the flag as Set does, for a caller that may have to take it away again, as a write that raised it for itself and did not land. It returns nil when the flag was raised already, as it is not the caller's to take away. The flag returned, raised even with an error, as a file created and not synced, is to be kept or lowered.

func (*Raised) Keep

func (t *Raised) Keep() error

Keep leaves the flag raised.

func (*Raised) Lower

func (t *Raised) Lower() error

Lower takes the flag away while it is the file Raise created: a flag another raised after it was removed is left alone. The check and the removal are made under the lock of the flag, so no other change of the flag lands between the two.

Jump to

Keyboard shortcuts

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