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 ¶
- type Archive
- type MockArchive
- type MockArchiveMockRecorder
- type MockArchiveOpenCall
- func (c *MockArchiveOpenCall) Do(f func(context.Context, string) (Session, error)) *MockArchiveOpenCall
- func (c *MockArchiveOpenCall) DoAndReturn(f func(context.Context, string) (Session, error)) *MockArchiveOpenCall
- func (c *MockArchiveOpenCall) Return(arg0 Session, arg1 error) *MockArchiveOpenCall
- type MockSession
- type MockSessionCloseCall
- type MockSessionCommitCall
- type MockSessionMockRecorder
- type MockSessionPathCall
- type Session
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.
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 ¶
MockArchiveOpenCall wrap *gomock.Call
func (*MockArchiveOpenCall) Do ¶
func (c *MockArchiveOpenCall) Do(f func(context.Context, string) (Session, error)) *MockArchiveOpenCall
Do rewrite *gomock.Call.Do
func (*MockArchiveOpenCall) DoAndReturn ¶
func (c *MockArchiveOpenCall) DoAndReturn(f func(context.Context, string) (Session, error)) *MockArchiveOpenCall
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.
type MockSessionCloseCall ¶
MockSessionCloseCall wrap *gomock.Call
func (*MockSessionCloseCall) Do ¶
func (c *MockSessionCloseCall) Do(f func(context.Context)) *MockSessionCloseCall
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 ¶
func (c *MockSessionCloseCall) Return() *MockSessionCloseCall
Return rewrite *gomock.Call.Return
type MockSessionCommitCall ¶
MockSessionCommitCall wrap *gomock.Call
func (*MockSessionCommitCall) Do ¶
func (c *MockSessionCommitCall) Do(f func(context.Context, string) error) *MockSessionCommitCall
Do rewrite *gomock.Call.Do
func (*MockSessionCommitCall) DoAndReturn ¶
func (c *MockSessionCommitCall) DoAndReturn(f func(context.Context, string) error) *MockSessionCommitCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockSessionCommitCall) Return ¶
func (c *MockSessionCommitCall) Return(arg0 error) *MockSessionCommitCall
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 ¶
func (mr *MockSessionMockRecorder) Close(ctx any) *MockSessionCloseCall
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 ¶
func (mr *MockSessionMockRecorder) Path() *MockSessionPathCall
Path indicates an expected call of Path.
type MockSessionPathCall ¶
MockSessionPathCall wrap *gomock.Call
func (*MockSessionPathCall) Do ¶
func (c *MockSessionPathCall) Do(f func() string) *MockSessionPathCall
Do rewrite *gomock.Call.Do
func (*MockSessionPathCall) DoAndReturn ¶
func (c *MockSessionPathCall) DoAndReturn(f func() string) *MockSessionPathCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockSessionPathCall) Return ¶
func (c *MockSessionPathCall) Return(arg0 string) *MockSessionPathCall
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. |