memfile

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 13 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// DefaultMaxGuideFileSize is the default maximum size of a state chunk file in bytes.
	DefaultMaxGuideFileSize = 1048576

	// DefaultMaxEventParititionSize is the default maximum size of an event partition in bytes.
	// When trying to save a new event that would exceed this size, the `memfile` state container
	// implementation will fail.
	DefaultMaxEventParititionSize = 10485760
)

Variables

This section is empty.

Functions

func NewFSStorage added in v0.10.0

func NewFSStorage(fs afero.Fs) statestore.Storage

NewFSStorage returns the Storage that backs a memfile state container, keys being paths on the given filesystem.

Exported so a caller can wrap it with storage decorators such as statestore.NewEncryptedStorage used to encrypt state at rest.

func WithClock

func WithClock(clock commoncore.Clock) func(*StateContainer)

WithClock sets the clock to use for the state container. This is used in tasks like determining the current time when checking for recently queued events.

When not set, the default value is the system clock.

func WithMaxEventPartitionSize

func WithMaxEventPartitionSize(maxEventPartitionSize int64) func(*StateContainer)

WithMaxEventPartitionSize sets a maximum size of an event partition file in bytes. If the addition of a new event causes the partition to exceeds this size, an error will be returned for the save event operation. This determines the maximum size of the data in the partition file, depending on the operating system and file system, the actual size of the file will in most cases be larger.

When not set, the default value is 10MB (10,485,760 bytes).

func WithMaxGuideFileSize

func WithMaxGuideFileSize(maxGuideFileSize int64) func(*StateContainer)

WithMaxGuideFileSize sets a guide for the maximum size of a state chunk file in bytes. If a single record (instance or resource drift entry) exceeds this size, it will not be split into multiple files. This is only a guide, the actual size of the files are often likely to be larger.

When not set, the default value is 1MB (1,048,576 bytes).

func WithRecentlyQueuedEventsThreshold

func WithRecentlyQueuedEventsThreshold(thresholdSeconds int64) func(*StateContainer)

WithRecentlyQueuedEventsThreshold sets the threshold in seconds for retrieving recently queued events for a stream when a starting event ID is not provided.

When not set, the default value is 5 minutes (300 seconds).

Types

type Option

type Option func(*StateContainer)

Option is a type for options that can be passed to LoadStateContainer when creating an in-memory state container with file persistence.

type StateContainer

type StateContainer struct {
	// contains filtered or unexported fields
}

StateContainer provides the in-memory with file persistence (memfile) implementation of the blueprint `state.Container` interface along with methods to manage persistence for blueprint validation requests, events and change sets.

func LoadStateContainer

func LoadStateContainer(
	stateDir string,
	fs afero.Fs,
	logger core.Logger,
	opts ...Option,
) (*StateContainer, error)

LoadStateContainer loads a new state container that uses in-process memory to store state with local files used for persistence. State is loaded from stateDir at construction time via statestore.Load; subsequent writes go back to the same directory. stateDir can be relative to the current working directory or an absolute path.

func LoadStateContainerWithStorage added in v0.10.0

func LoadStateContainerWithStorage(
	stateDir string,
	storage statestore.Storage,
	logger core.Logger,
	opts ...Option,
) (*StateContainer, error)

LoadStateContainerWithStorage loads a state container over a Storage the caller supplies, rather than one built directly over a filesystem.

For callers that need to decorate what memfile persists through, statestore.NewEncryptedStorage over a NewFSStorage being the case this exists for. Anything that has to be read or written outside the decorator, an encryption salt for instance, must be handled before the container is loaded, since loading reads the whole store.

func (*StateContainer) Audit added in v0.11.0

func (c *StateContainer) Audit() manage.Audit

func (*StateContainer) Changesets

func (c *StateContainer) Changesets() manage.Changesets

func (*StateContainer) Children

func (c *StateContainer) Children() state.ChildrenContainer

func (*StateContainer) CleanupOperations added in v0.6.0

func (c *StateContainer) CleanupOperations() manage.CleanupOperations

func (*StateContainer) Events

func (c *StateContainer) Events() manage.Events

func (*StateContainer) Exports

func (c *StateContainer) Exports() state.ExportsContainer

func (*StateContainer) Instances

func (c *StateContainer) Instances() state.InstancesContainer
func (c *StateContainer) Links() state.LinksContainer

func (*StateContainer) Metadata

func (c *StateContainer) Metadata() state.MetadataContainer

func (*StateContainer) ReconciliationResults added in v0.5.0

func (c *StateContainer) ReconciliationResults() manage.ReconciliationResults

func (*StateContainer) Resources

func (c *StateContainer) Resources() state.ResourcesContainer

func (*StateContainer) Validation

func (c *StateContainer) Validation() manage.Validation

Jump to

Keyboard shortcuts

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