types

package
v1.23.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RawState

type RawState = map[string]any

RawState is used to hold a weak type in-memory representation of the state.

type State

type State interface {
	// Load reads the state from the storage into the memory.
	Load() error

	// Save writes the state from the memory into the storage.
	Save() error

	// Loaded returns true if the state is loaded into the memory.
	Loaded() bool

	// Changed returns true if the in-memory state has changed.
	Changed() bool

	// Get retrieves the state for the key into the state entry which must be
	// provided as pointer see example.
	//
	// For example:
	//
	//     type T struct {
	//         F int `yaml:"a,omitempty"`
	//         B int
	//     }
	//     var t T
	//     State.Get("my_key", &t)
	//
	Get(StateEntryKey, StateEntry) error

	// Set updates the state entry for the key. The state entry must not be
	// provided as pointer see example.
	//
	// For example:
	//
	//     type T struct {
	//         F int `yaml:"a,omitempty"`
	//         B int
	//     }
	//     var t T
	//     State.Set("my_key", t)
	//
	Set(StateEntryKey, StateEntry) error
}

type StateEntry

type StateEntry = interface{}

type StateEntryKey

type StateEntryKey = string

type StateStorage

type StateStorage interface {
	// Read loads the state from the storage.
	//
	// Must not return an error in case the state does not exist in the
	// storage but an empty RawState.
	Read() (RawState, error)

	// Write saves the state to the storage.
	Write(RawState) error

	// TagName returns the tag name used for additional field configuration.
	TagName() string
}

Jump to

Keyboard shortcuts

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