opentofu/states/statemgr/statemgr.go
Martin Atkins 3bb731e2d6 statemgr: Helper funcs RefreshAndRead and WriteAndPersist
In practice these pairs of functions are often used together when working
with a "full" statemgr, so these helper wrappers allow us to do that more
conveniently.

This also introduces a new interface statemgr.Storage, which represents
a state manager that has all of the storage capabilities but does not
necessarily support locking. In practice callers will usually just use
statemgr.Full, but these more-specific interfaces allow us to reflect
in APIs which subset of the statemgr functionality each function depends
on.
2018-10-16 18:58:49 -07:00

27 lines
875 B
Go

package statemgr
// Storage is the union of Transient and Persistent, for state managers that
// have both transient and persistent storage.
//
// Types implementing this interface coordinate between their Transient
// and Persistent implementations so that the persistent operations read
// or write the transient store.
type Storage interface {
Transient
Persistent
}
// Full is the union of all of the more-specific state interfaces.
//
// This interface may grow over time, so state implementations aiming to
// implement it may need to be modified for future changes. To ensure that
// this need can be detected, always include a statement nearby the declaration
// of the implementing type that will fail at compile time if the interface
// isn't satisfied, such as:
//
// var _ statemgr.Full = (*ImplementingType)(nil)
type Full interface {
Storage
Locker
}