Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FSLockGroup ¶
type FSLockGroup struct {
// contains filtered or unexported fields
}
FSLockGroup is a Group implementation that uses filesystem locks for mutual exclusion. It uses the gofrs/flock library to ensure only one execution happens for a given key at a time across all goroutines and processes. Unlike SingleflightGroup, this does not share results within the same process - each caller will execute the function once they acquire the lock.
func NewFlockGroup ¶
func NewFlockGroup(lockDir string) (*FSLockGroup, error)
NewFlockGroup creates a new FlockGroup. lockDir is the directory where lock files will be created. If lockDir is empty, it defaults to os.TempDir()/gobuildcache-locks.
func (*FSLockGroup) DoWithLock ¶
func (g *FSLockGroup) DoWithLock(key string, fn func() (interface{}, error)) (v interface{}, err error)
Do executes and returns the results of the given function using filesystem locks. Only one execution will occur for a given key at a time across all processes. The shared return value is always false since this implementation provides mutual exclusion rather than result sharing.
type Group ¶
type Group interface {
// DoWithLock runs the given function with mutual exclusion over the given key.
DoWithLock(key string, fn func() (interface{}, error)) (v interface{}, err error)
}
locking.Group is an abstraction for running functions with mutual exclusion over sets of keys.
type MemLock ¶
MemLock is a Group implementation that uses in-memory locks (mutexes) for mutual exclusuion. It only works within a single gobuildcache process and doesn't work if there are multiple gobuildcache processes running concurrently on the same filesystem. It's used primarily in tests.
func NewMemLock ¶
func NewMemLock() *MemLock