statearchive

package
v0.60.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package statearchive is a generated GoMock package.

Package statearchive defines a pluggable archive for durable Radius state that is exported out of a running cluster and restored later (for example across ephemeral CI runs).

It is intentionally distinct from the live, record-oriented persistence subsystems in pkg/components (database.Client, secret.Client, queue.Client): those serve the running control plane, whereas an Archive captures a whole directory of state as a durable snapshot. Today the only implementation is a git orphan branch (pkg/statearchive/git), but the interface deliberately hides that: a Session is just a local working directory whose contents survive across Open calls once Commit succeeds. Callers write files into Session.Path() with any tool (pg_dump, kubectl, os.WriteFile, ...), then Commit to persist them. Alternative implementations (for example OCI/GHCR or a plain filesystem) implement the same two interfaces without changing any caller.

Typical use:

session, err := archive.Open(ctx, "radius-state")
if err != nil {
	return err
}
defer session.Close(ctx)
// ... read/write files under session.Path() ...
if err := session.Commit(ctx, "radius: backup"); err != nil {
	return err
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive interface {
	// Open materializes the durable archive identified by name into a local
	// working directory and returns a Session. Files persisted by a previous
	// Commit are present under Session.Path() when Open returns. The caller
	// must always defer Session.Close.
	Open(ctx context.Context, name string) (Session, error)
}

Archive is a pluggable durable state archive. Each named archive is materialized into a local working directory (a Session) that callers mutate with any tool and then persist atomically via Session.Commit.

Implementations must be safe for concurrent use by multiple goroutines. An implementation is free to serialize concurrent Open calls for the same name when its underlying storage cannot support simultaneous sessions (the git implementation does this because git refuses two worktrees on one branch).

type MockArchive

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

MockArchive is a mock of Archive interface.

func NewMockArchive

func NewMockArchive(ctrl *gomock.Controller) *MockArchive

NewMockArchive creates a new mock instance.

func (*MockArchive) EXPECT

func (m *MockArchive) EXPECT() *MockArchiveMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockArchive) Open

func (m *MockArchive) Open(ctx context.Context, name string) (Session, error)

Open mocks base method.

type MockArchiveMockRecorder

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

MockArchiveMockRecorder is the mock recorder for MockArchive.

func (*MockArchiveMockRecorder) Open

func (mr *MockArchiveMockRecorder) Open(ctx, name any) *MockArchiveOpenCall

Open indicates an expected call of Open.

type MockArchiveOpenCall

type MockArchiveOpenCall struct {
	*gomock.Call
}

MockArchiveOpenCall wrap *gomock.Call

func (*MockArchiveOpenCall) Do

Do rewrite *gomock.Call.Do

func (*MockArchiveOpenCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockArchiveOpenCall) Return

func (c *MockArchiveOpenCall) Return(arg0 Session, arg1 error) *MockArchiveOpenCall

Return rewrite *gomock.Call.Return

type MockSession

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

MockSession is a mock of Session interface.

func NewMockSession

func NewMockSession(ctrl *gomock.Controller) *MockSession

NewMockSession creates a new mock instance.

func (*MockSession) Close

func (m *MockSession) Close(ctx context.Context)

Close mocks base method.

func (*MockSession) Commit

func (m *MockSession) Commit(ctx context.Context, message string) error

Commit mocks base method.

func (*MockSession) EXPECT

func (m *MockSession) EXPECT() *MockSessionMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSession) Path

func (m *MockSession) Path() string

Path mocks base method.

type MockSessionCloseCall

type MockSessionCloseCall struct {
	*gomock.Call
}

MockSessionCloseCall wrap *gomock.Call

func (*MockSessionCloseCall) Do

Do rewrite *gomock.Call.Do

func (*MockSessionCloseCall) DoAndReturn

func (c *MockSessionCloseCall) DoAndReturn(f func(context.Context)) *MockSessionCloseCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockSessionCloseCall) Return

Return rewrite *gomock.Call.Return

type MockSessionCommitCall

type MockSessionCommitCall struct {
	*gomock.Call
}

MockSessionCommitCall wrap *gomock.Call

func (*MockSessionCommitCall) Do

Do rewrite *gomock.Call.Do

func (*MockSessionCommitCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockSessionCommitCall) Return

Return rewrite *gomock.Call.Return

type MockSessionMockRecorder

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

MockSessionMockRecorder is the mock recorder for MockSession.

func (*MockSessionMockRecorder) Close

Close indicates an expected call of Close.

func (*MockSessionMockRecorder) Commit

func (mr *MockSessionMockRecorder) Commit(ctx, message any) *MockSessionCommitCall

Commit indicates an expected call of Commit.

func (*MockSessionMockRecorder) Path

Path indicates an expected call of Path.

type MockSessionPathCall

type MockSessionPathCall struct {
	*gomock.Call
}

MockSessionPathCall wrap *gomock.Call

func (*MockSessionPathCall) Do

Do rewrite *gomock.Call.Do

func (*MockSessionPathCall) DoAndReturn

func (c *MockSessionPathCall) DoAndReturn(f func() string) *MockSessionPathCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockSessionPathCall) Return

Return rewrite *gomock.Call.Return

type Session

type Session interface {
	// Path is the absolute path of the local working directory backing the
	// session. It is stable for the lifetime of the session.
	Path() string

	// Commit persists every change made under Path since Open (or the previous
	// Commit) to durable storage. When there is nothing to persist it is a
	// no-op. A Commit either durably persists the state or returns an error;
	// it never silently drops changes.
	Commit(ctx context.Context, message string) error

	// Close releases the session's resources. It is best-effort cleanup and is
	// safe to call from a deferred statement; failures are logged rather than
	// returned so they cannot mask the real error on the happy path.
	Close(ctx context.Context)
}

Session is a durable working directory. Callers read and write files under Path using ordinary filesystem operations, Commit persists every change made under Path, and Close releases any resources the session holds.

Directories

Path Synopsis
Package factory selects a state archive implementation from environment configuration.
Package factory selects a state archive implementation from environment configuration.
Package git implements the statearchive.Archive interface on top of a git orphan branch.
Package git implements the statearchive.Archive interface on top of a git orphan branch.
Package oci implements the statearchive.Archive interface with OCI artifacts.
Package oci implements the statearchive.Archive interface with OCI artifacts.

Jump to

Keyboard shortcuts

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