statemanager

package
v1.18.0-coveo.4 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2018 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 10 Imported by: 0

Documentation

Overview

Package statemanager implements simple constructs for saving and restoring state from disk. It provides the interface for a StateManager which can read/write arbitrary json data from/to disk.

Index

Constants

View Source
const (
	// ECSDataVersion is the current version of saved data. Any backwards or
	// forwards incompatible changes to the data-format should increment this number
	// and retain the ability to read old data versions.
	// Version changes:
	// 1) initial
	// 2)
	//   a) Add 'ACSSeqNum' top level field (backwards compatible; technically
	//      forwards compatible but could cause resource constraint violations)
	//   b) remove 'DEAD', 'UNKNOWN' state from ever being marshalled (backward and
	//      forward compatible)
	// 3) Add 'Protocol' field to 'portMappings' and 'KnownPortBindings'
	// 4) Add 'DockerConfig' struct
	// 5) Add 'ImageStates' struct as part of ImageManager
	// 6)
	//   a) Refactor 'Internal' field in 'api.Container' to 'Type' enum
	//   b) Add 'ContainerResourcesProvisioned' as a new 'ContainerStatus' enum
	//   c) Add 'SteadyStateStatus' field to 'Container' struct
	//   d) Add 'ENIAttachments' struct
	//   e) Deprecate 'SteadyStateDependencies' in favor of 'TransitionDependencySet'
	// 7)
	//   a) Add 'MetadataUpdated' field to 'api.Container'
	//   b) Add 'DomainNameServers' and 'DomainNameSearchList' in 'api.ENI'
	// 8)
	//   a) Add 'UseExecutionRole' in 'api.ECRAuthData'
	//   b) Add 'executionCredentialsID' in 'api.Task'
	//   c) Add 'LogsAuthStrategy' field to 'api.Container'
	//   d) Added task cgroup related fields ('CPU', 'Memory', 'MemoryCPULimitsEnabled') to 'api.Task'
	// 9) Add 'ipToTask' map to state file
	// 10) Add 'healthCheckType' field in 'api.Container'
	// 11)
	//  a) Add 'PrivateDNSName' field to 'api.ENI'
	//  b)Remove 'AppliedStatus' field from 'api.Container'
	// 12) Add 'PullSucceeded' field to 'ImageState'
	ECSDataVersion = 12
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NoopStateManager

type NoopStateManager struct{}

NoopStateManager is a state manager that succeeds for all reads/writes without even trying; it allows disabling of state serialization by being a drop-in replacement so no other code need be concerned with it.

func (*NoopStateManager) ForceSave added in v1.0.0

func (nsm *NoopStateManager) ForceSave() error

ForceSave does nothing, successfully

func (*NoopStateManager) Load

func (nsm *NoopStateManager) Load() error

Load does nothing, successfully

func (*NoopStateManager) Save

func (nsm *NoopStateManager) Save() error

Save does nothing, successfully

type Option

type Option func(StateManager)

Option functions are functions that may be used as part of constructing a new StateManager

func AddSaveable

func AddSaveable(name string, saveable Saveable) Option

AddSaveable is an option that adds a given saveable as one that should be saved under the given name. The name must be the same across uses of the statemanager (e.g. program invocations) for it to be serialized and deserialized correctly.

type Saveable

type Saveable interface{}

Saveable types should be able to be json serializable and deserializable Properly, this should have json.Marshaler/json.Unmarshaler here, but string and so on can be marshaled/unmarshaled sanely but don't fit those interfaces.

type Saver

type Saver interface {
	Save() error
	ForceSave() error
}

Saver is a type that can be saved

type StateManager

type StateManager interface {
	Saver
	Load() error
}

A StateManager can load and save state from disk. Load is not expected to return an error if there is no state to load.

func NewNoopStateManager

func NewNoopStateManager() StateManager

NewNoopStateManager constructs a state manager

func NewStateManager

func NewStateManager(cfg *config.Config, options ...Option) (StateManager, error)

NewStateManager constructs a new StateManager which saves data at the location specified in cfg and operates under the given options. The returned StateManager will not save more often than every 10 seconds and will not reliably return errors with Save, but will log them appropriately.

Directories

Path Synopsis
Package mock_statemanager is a generated GoMock package.
Package mock_statemanager is a generated GoMock package.

Jump to

Keyboard shortcuts

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