{"modulePath":"github.com/dockerstack/amazon-ecs-agent","version":"v1.2.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package statemanager\n\nPackage 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.\n\n## Constants\n\n```go\nconst EcsDataVersion = 3\n```\nThe 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)\n\n\ta) Add 'ACSSeqNum' top level field (backwards compatible; technically\n\t   forwards compatible but could cause resource constraint violations)\n\tb) remove 'DEAD', 'UNKNOWN' state from ever being marshalled (backward and\n\t   forward compatible)\n\n3\\) Add 'Protocol' field to 'portMappings' and 'KnownPortBindings'\n\n## Types\n\n```go\ntype NoopStateManager struct{}\n```\nNoopStateManager 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.\n\n```go\nfunc (nsm *NoopStateManager) ForceSave() error\n```\nForceSave does nothing, successfully\n\n```go\nfunc (nsm *NoopStateManager) Load() error\n```\nLoad does nothing, successfully\n\n```go\nfunc (nsm *NoopStateManager) Save() error\n```\nSave does nothing, successfully\n\n```go\ntype Option func(StateManager)\n```\nOption functions are functions that may be used as part of constructing a new StateManager\n\n```go\nfunc AddSaveable(name string, saveable Saveable) Option\n```\nAddSaveable 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.\n\n```go\ntype Saveable interface{}\n```\nSaveable 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.\n\n```go\ntype Saver interface {\n\tSave() error\n\tForceSave() error\n}\n```\nSaver is a type that can be saved\n\n```go\ntype StateManager interface {\n\tSaver\n\tLoad() error\n}\n```\nA StateManager can load and save state from disk. Load is not expected to return an error if there is no state to load.\n\n```go\nfunc NewNoopStateManager() StateManager\n```\nNewNoopStateManager constructs a state manager\n\n```go\nfunc NewStateManager(cfg *config.Config, options ...Option) (StateManager, error)\n```\nNewStateManager 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.\n\n","path":"github.com/dockerstack/amazon-ecs-agent/agent/statemanager","name":"statemanager","synopsis":"Package statemanager implements simple constructs for saving and restoring state from disk.","isRedistributable":true}
