remote

package
v0.12.26 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuiltinClients = map[string]Factory{}

BuiltinClients is the list of built-in clients that can be used with NewClient.

Functions

func TestClient added in v0.9.0

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

TestClient is a generic function to test any client.

func TestRemoteLocks added in v0.9.0

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.

func NewClient

func NewClient(t string, conf map[string]string) (Client, error)

NewClient returns a new Client with the given type and configuration. The client is looked up in the BuiltinClients variable.

type ClientForcePusher added in v0.12.25

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 added in v0.9.0

type ClientLocker interface {
	Client
	state.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 added in v0.12.0

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 added in v0.9.0

func (s *State) Lock(info *state.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 added in v0.12.0

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

StateForMigration is part of our implementation of statemgr.Migrator.

func (*State) StateSnapshotMeta added in v0.12.0

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 added in v0.9.0

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 added in v0.12.0

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