Help us shape the future of Go! Take the 2026 Go Developer Survey

readmodeltest

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package readmodeltest holds in-memory doubles of the read model's store and flow store for tests of the transports above it. They serve fixtures and record the queries they receive; the aggregation itself is the Postgres store's and is tested there.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("readmodeltest: not supported by the double")

ErrUnsupported is returned by the flow store double for writes.

Functions

func SyncRank

func SyncRank(s innerwallv1.SyncState, ownedTable innerwallv1.OwnedTableState) int32

SyncRank is the fleet order of a workload, as the store ranks it: a removed owned table or degraded, then offline, pending, synced, then anything else. A removed table outranks every stored sync state, which it leaves as recorded (issue #96).

Types

type MemFlows

type MemFlows struct {
	Result    *flowstore.GroupResult
	Rows      []flowstore.WindowRow
	Err       error
	LastGroup *flowstore.GroupQuery
	LastPage  *flowstore.WindowPageQuery
	Gaps      []flowstore.GapRow
	LastGaps  *flowstore.GapQuery
	// contains filtered or unexported fields
}

MemFlows implements flowstore.FlowStore over fixtures: it returns the grouped result and rows it holds and records the queries it received.

func (*MemFlows) ListGaps

ListGaps implements flowstore.FlowStore: the held gaps of the queried workloads intersecting the range, as the statement selects them, newest first, at most the limit.

func (*MemFlows) ListTotals

ListTotals implements flowstore.FlowStore.

func (*MemFlows) ListWindowPage

ListWindowPage implements flowstore.FlowStore: the rows after the cursor in (window start, id) descending order, at most the limit.

func (*MemFlows) ListWindows

ListWindows implements flowstore.FlowStore.

func (*MemFlows) PruneWindows

func (f *MemFlows) PruneWindows(context.Context, time.Time) (int64, bool, error)

PruneWindows implements flowstore.FlowStore.

func (*MemFlows) Rollup

Rollup implements flowstore.FlowStore.

func (*MemFlows) RollupGroups

RollupGroups implements flowstore.FlowStore.

func (*MemFlows) WriteGaps added in v0.3.0

WriteGaps implements flowstore.FlowStore.

func (*MemFlows) WriteWindow

func (f *MemFlows) WriteWindow(context.Context, flowstore.Window) (int, error)

WriteWindow implements flowstore.FlowStore.

type MemStore

type MemStore struct {
	Workloads     []readmodel.WorkloadRecord
	AddressGroups []policy.AddressGroup
	Rulesets      []policy.Ruleset
	Policies      map[identity.WorkloadID]*innerwallv1.WorkloadPolicy
	// LastPage is the last page query received.
	LastPage *readmodel.WorkloadPageQuery
	// contains filtered or unexported fields
}

MemStore implements readmodel.Store over fixtures.

func (*MemStore) CountWorkloadsByStatus added in v0.2.0

func (m *MemStore) CountWorkloadsByStatus(context.Context) ([]readmodel.StatusCount, error)

CountWorkloadsByStatus implements readmodel.Store: a pair no fixture holds is absent, as it is from the Postgres statement.

func (*MemStore) GetWorkloadPolicy

func (m *MemStore) GetWorkloadPolicy(_ context.Context, id identity.WorkloadID) (*innerwallv1.WorkloadPolicy, error)

GetWorkloadPolicy implements readmodel.Store.

func (*MemStore) GetWorkloadRecord

func (m *MemStore) GetWorkloadRecord(_ context.Context, id identity.WorkloadID) (*readmodel.WorkloadRecord, error)

GetWorkloadRecord implements readmodel.Store.

func (*MemStore) ListAddressGroups

func (m *MemStore) ListAddressGroups(context.Context) ([]policy.AddressGroup, error)

ListAddressGroups implements readmodel.Store.

func (*MemStore) ListRulesets

func (m *MemStore) ListRulesets(context.Context) ([]policy.Ruleset, error)

ListRulesets implements readmodel.Store.

func (*MemStore) ListWorkloadLabelIndex

func (m *MemStore) ListWorkloadLabelIndex(context.Context) (map[identity.WorkloadID]map[string]string, error)

ListWorkloadLabelIndex implements readmodel.Store.

func (*MemStore) ListWorkloadPage

ListWorkloadPage implements readmodel.Store with the same order, filter, and cursor semantics as the Postgres statement.

func (*MemStore) ListWorkloads

func (m *MemStore) ListWorkloads(context.Context) ([]registry.Workload, error)

ListWorkloads implements readmodel.Store.

Jump to

Keyboard shortcuts

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