remote

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestClient

func TestClient(t *testing.T, c Client)

TestClient is a generic function to test any client.

func TestRemoteLocks

func TestRemoteLocks(t *testing.T, a, b Client)

Test the lock implementation for a remote.Client. This test requires 2 client instances, in oder to have multiple remote clients since some implementations may tie the client to the lock, or may have reentrant locks.

Types

type Client

type Client interface {
	Get() (*Payload, error)
	Put([]byte) error
	Delete() error
}

Client is the interface that must be implemented for a remote state driver. It supports dumb put/get/delete, and the higher level structs handle persisting the state properly here.

type ClientForcePusher

type ClientForcePusher interface {
	Client
	EnableForcePush()
}

ClientForcePusher is an optional interface that allows a remote state to force push by managing a flag on the client that is toggled on by a call to EnableForcePush.

type ClientLocker

type ClientLocker interface {
	Client
	statemgr.Locker
}

ClientLocker is an optional interface that allows a remote state backend to enable state lock/unlock.

type Factory

type Factory func(map[string]string) (Client, error)

Factory is the factory function to create a remote client.

type Payload

type Payload struct {
	MD5  []byte
	Data []byte
}

Payload is the return value from the remote state storage.

type State

type State struct {
	Client Client
	// contains filtered or unexported fields
}

State implements the State interfaces in the state package to handle reading and writing the remote state. This State on its own does no local caching so every persist will go to the remote storage and local writes will go to memory.

func (*State) DisableLocks

func (s *State) DisableLocks()

DisableLocks turns the Lock and Unlock methods into no-ops. This is intended to be called during initialization of a state manager and should not be called after any of the statemgr.Full interface methods have been called.

func (*State) Lock

func (s *State) Lock(info *statemgr.LockInfo) (string, error)

Lock calls the Client's Lock method if it's implemented.

func (*State) PersistState

func (s *State) PersistState() error

statemgr.Persister impl.

func (*State) RefreshState

func (s *State) RefreshState() error

statemgr.Refresher impl.

func (*State) State

func (s *State) State() *states.State

statemgr.Reader impl.

func (*State) StateForMigration

func (s *State) StateForMigration() *statefile.File

StateForMigration is part of our implementation of statemgr.Migrator.

func (*State) StateSnapshotMeta

func (s *State) StateSnapshotMeta() statemgr.SnapshotMeta

StateSnapshotMeta returns the metadata from the most recently persisted or refreshed persistent state snapshot.

This is an implementation of statemgr.PersistentMeta.

func (*State) Unlock

func (s *State) Unlock(id string) error

Unlock calls the Client's Unlock method if it's implemented.

func (*State) WriteState

func (s *State) WriteState(state *states.State) error

statemgr.Writer impl.

func (*State) WriteStateForMigration

func (s *State) WriteStateForMigration(f *statefile.File, force bool) error

WriteStateForMigration is part of our implementation of statemgr.Migrator.

Jump to

Keyboard shortcuts

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