volumemanager

package
v0.0.0-...-b359386 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchProvider = errors.New("no such provider")
	ErrProviderExists = errors.New("provider exists")
	ErrVolumeExists   = errors.New("volume exists")
)
View Source
var ErrDBClosed = errors.New("volume persistence db is closed")

Functions

func NewProvider

func NewProvider(pspec *volume.ProviderSpec) (provider volume.Provider, err error)

Types

type Manager

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

volume.Manager providers interfaces for both provisioning volume backends, and then creating volumes using them.

There is one volume.Manager per host daemon process.

func New

func New(dbPath string, logger log15.Logger, defaultProvider func() (volume.Provider, error)) *Manager

func (*Manager) AddProvider

func (m *Manager) AddProvider(id string, p volume.Provider) error

func (*Manager) CloseDB

func (m *Manager) CloseDB() error

CloseDB closes the persistence DB.

The DB mutex is locked to protect m.db, but also prevents closing the DB when it could still be needed to service API requests (see LockDB).

func (*Manager) CreateSnapshot

func (m *Manager) CreateSnapshot(id string) (volume.Volume, error)

func (*Manager) DestroyVolume

func (m *Manager) DestroyVolume(id string) error

func (*Manager) ForkVolume

func (m *Manager) ForkVolume(id string) (volume.Volume, error)

func (*Manager) GetVolume

func (m *Manager) GetVolume(id string) volume.Volume

func (*Manager) ImportFilesystem

func (m *Manager) ImportFilesystem(providerID string, fs *volume.Filesystem) (volume.Volume, error)

func (*Manager) ListHaves

func (m *Manager) ListHaves(id string) ([]json.RawMessage, error)

func (*Manager) LockDB

func (m *Manager) LockDB() error

LockDB acquires a read lock on the DB mutex so that it cannot be closed until the caller has finished performing actions which will lead to changes being persisted to the DB.

For example, creating a volume first delegates to the provider to create the volume and then persists to the DB, but if the DB is closed in that time then the volume state will be lost.

ErrDBClosed is returned if the DB is already closed so API requests will fail before any actions are performed.

func (*Manager) NewVolume

func (m *Manager) NewVolume(info *volume.Info) (volume.Volume, error)

volume.Manager implements the volume.Provider interface by delegating NewVolume requests to the default Provider.

func (*Manager) NewVolumeFromProvider

func (m *Manager) NewVolumeFromProvider(providerID string, info *volume.Info) (volume.Volume, error)

volume.Manager implements the volume.Provider interface by delegating NewVolume requests to the named Provider.

func (*Manager) OpenDB

func (m *Manager) OpenDB() error

OpenDB opens and initialises the persistence DB, if not already open.

func (*Manager) ReceiveSnapshot

func (m *Manager) ReceiveSnapshot(id string, stream io.Reader) (volume.Volume, error)

func (*Manager) SendSnapshot

func (m *Manager) SendSnapshot(id string, haves []json.RawMessage, stream io.Writer) error

func (*Manager) Subscribe

func (m *Manager) Subscribe() chan *volume.Event

func (*Manager) UnlockDB

func (m *Manager) UnlockDB()

UnlockDB releases a read lock on the DB mutex, previously acquired by a call to LockDB.

func (*Manager) Unsubscribe

func (m *Manager) Unsubscribe(ch chan *volume.Event)

func (*Manager) Volumes

func (m *Manager) Volumes() map[string]volume.Volume

Jump to

Keyboard shortcuts

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