volwatch

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Create is a volume creation event
	Create = iota
	// Remove is a volume deletion event
	Remove
)

Variables

This section is empty.

Functions

func IDDevicePath

func IDDevicePath(target string) string

IDDevicePath gives the full path to the target in the deviceDir

Types

type Event

type Event []string

Event is returned by the events channel

func (Event) Volumes

func (e Event) Volumes() []string

Volumes extracts the list of volumes from an Event type

type VolumeWatcher

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

VolumeWatcher watches the disk area for new volumes and posts them to the Events channel

Create a VolumeWatcher by calling the NewWatcher function

func NewWatchDir

func NewWatchDir(dir string) *VolumeWatcher

NewWatchDir creates a new volume watcher on an arbitrary directory

func NewWatcher

func NewWatcher() *VolumeWatcher

NewWatcher creates a new volume watcher. It launches a separate Go routine in a separate context which watches for volumes being created and removed. The watcher can be cancelled by calling the returned context cancellation function

func (*VolumeWatcher) Cancel

func (vw *VolumeWatcher) Cancel()

Cancel signals to the watcher that it should stop watching and close down

func (*VolumeWatcher) Done

func (vw *VolumeWatcher) Done() <-chan struct{}

Done returns a channel that is closed when the watcher has been cancelled

func (*VolumeWatcher) Err

func (vw *VolumeWatcher) Err() error

Err returns a Cancelled error when the watcher has been stopped

func (*VolumeWatcher) Events

func (vw *VolumeWatcher) Events() <-chan Event

Events returns the main events channel

Jump to

Keyboard shortcuts

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