clustvirt/cluster/lock/lock.go

20 lines
684 B
Go
Raw Normal View History

// Package lock implements a locking mechanism on shared resources to ensure
// they don't get used at the same time. There needs to be a lock for the following:
// - VM on Host: A VM must only exist on one host at a time
// - Storage attached to VM: Block storage can only be attached to one VM at a time
package lock
// Locker interface used to lock and unlock Lockable resources
type Locker interface {
Lock(Lockable) error
Unlock(Lockable) error
}
// Lockable interface must be attached to lockable resources, such as
// Virtual Machines, block devices, and host devices that can be attached
// to virtual machines.
type Lockable interface {
Locked() bool
HeldBy() Locker
}