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 ¶
- Variables
- func SyncRank(s innerwallv1.SyncState, ownedTable innerwallv1.OwnedTableState) int32
- type MemFlows
- func (f *MemFlows) ListGaps(_ context.Context, q flowstore.GapQuery) ([]flowstore.GapRow, error)
- func (f *MemFlows) ListTotals(context.Context, identity.WorkloadID, innerwallv1.PolicyDecision) ([]flowstore.Total, error)
- func (f *MemFlows) ListWindowPage(_ context.Context, q flowstore.WindowPageQuery) ([]flowstore.WindowRow, error)
- func (f *MemFlows) ListWindows(context.Context, flowstore.WindowQuery) ([]flowstore.WindowRow, error)
- func (f *MemFlows) PruneWindows(context.Context, time.Time) (int64, bool, error)
- func (f *MemFlows) Rollup(context.Context, flowstore.RollupQuery) ([]flowstore.RollupRow, error)
- func (f *MemFlows) RollupGroups(_ context.Context, q flowstore.GroupQuery) (*flowstore.GroupResult, error)
- func (f *MemFlows) WriteGaps(context.Context, identity.WorkloadID, []flowstore.Gap) error
- func (f *MemFlows) WriteWindow(context.Context, flowstore.Window) (int, error)
- type MemStore
- func (m *MemStore) CountWorkloadsByStatus(context.Context) ([]readmodel.StatusCount, error)
- func (m *MemStore) GetWorkloadPolicy(_ context.Context, id identity.WorkloadID) (*innerwallv1.WorkloadPolicy, error)
- func (m *MemStore) GetWorkloadRecord(_ context.Context, id identity.WorkloadID) (*readmodel.WorkloadRecord, error)
- func (m *MemStore) ListAddressGroups(context.Context) ([]policy.AddressGroup, error)
- func (m *MemStore) ListRulesets(context.Context) ([]policy.Ruleset, error)
- func (m *MemStore) ListWorkloadLabelIndex(context.Context) (map[identity.WorkloadID]map[string]string, error)
- func (m *MemStore) ListWorkloadPage(_ context.Context, q readmodel.WorkloadPageQuery) ([]readmodel.WorkloadRecord, error)
- func (m *MemStore) ListWorkloads(context.Context) ([]registry.Workload, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
func (f *MemFlows) ListTotals(context.Context, identity.WorkloadID, innerwallv1.PolicyDecision) ([]flowstore.Total, error)
ListTotals implements flowstore.FlowStore.
func (*MemFlows) ListWindowPage ¶
func (f *MemFlows) ListWindowPage(_ context.Context, q flowstore.WindowPageQuery) ([]flowstore.WindowRow, error)
ListWindowPage implements flowstore.FlowStore: the rows after the cursor in (window start, id) descending order, at most the limit.
func (*MemFlows) ListWindows ¶
func (f *MemFlows) ListWindows(context.Context, flowstore.WindowQuery) ([]flowstore.WindowRow, error)
ListWindows implements flowstore.FlowStore.
func (*MemFlows) PruneWindows ¶
PruneWindows implements flowstore.FlowStore.
func (*MemFlows) RollupGroups ¶
func (f *MemFlows) RollupGroups(_ context.Context, q flowstore.GroupQuery) (*flowstore.GroupResult, error)
RollupGroups 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
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 ¶
ListAddressGroups implements readmodel.Store.
func (*MemStore) ListRulesets ¶
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 ¶
func (m *MemStore) ListWorkloadPage(_ context.Context, q readmodel.WorkloadPageQuery) ([]readmodel.WorkloadRecord, error)
ListWorkloadPage implements readmodel.Store with the same order, filter, and cursor semantics as the Postgres statement.