Documentation
¶
Index ¶
- Variables
- type AddAddressGroupCIDRParams
- type AddModeChangeWorkloadParams
- type AddProvisioningTokenLabelParams
- type AddRuleParams
- type AddRulePeerMatchParams
- type AddRulePeerParams
- type AddRuleServiceEntryParams
- type AddRuleServiceRefParams
- type AddRulesetScopeMatchParams
- type AddServiceEntryParams
- type AddWorkloadAddressParams
- type AddWorkloadLabelParams
- type AddWorkloadListeningServiceParams
- type AddressGroup
- type AddressGroupCidr
- type CountWorkloadsByStatusRow
- type CreateAddressGroupParams
- type CreateModeChangeParams
- type CreateOperatorSessionParams
- type CreateOperatorTokenParams
- type CreateProvisioningTokenParams
- type CreateRulesetParams
- type CreateServiceParams
- type CreateWorkloadParams
- type DBTX
- type DeleteAddressGroupParams
- type DeleteFlowGapsBeforeParams
- type DeleteFlowWindowsBeforeParams
- type DeleteRulesetParams
- type DeleteServiceParams
- type FlowGap
- type FlowTotal
- type FlowWindow
- type GetWorkloadModesRow
- type GetWorkloadWithPolicyRow
- type InsertFlowGapBatchResults
- type InsertFlowGapParams
- type InsertFlowWindowsParams
- type ListFlowGapsParams
- type ListFlowTotalsParams
- type ListFlowWindowPageParams
- type ListFlowWindowsParams
- type ListWorkloadPageParams
- type ListWorkloadPageRow
- type LockWorkloadRow
- type ModeChange
- type ModeChangeWorkload
- type NotifyDirectiveParams
- type NotifyPolicyChangedParams
- type Operator
- type OperatorSession
- type OperatorToken
- type ProvisioningToken
- type ProvisioningTokenLabel
- type Querier
- type Queries
- func (q *Queries) AcquireRenderLock(ctx context.Context, key int64) error
- func (q *Queries) AddAddressGroupCIDR(ctx context.Context, arg AddAddressGroupCIDRParams) error
- func (q *Queries) AddModeChangeWorkload(ctx context.Context, arg AddModeChangeWorkloadParams) error
- func (q *Queries) AddProvisioningTokenLabel(ctx context.Context, arg AddProvisioningTokenLabelParams) error
- func (q *Queries) AddRule(ctx context.Context, arg AddRuleParams) error
- func (q *Queries) AddRulePeer(ctx context.Context, arg AddRulePeerParams) error
- func (q *Queries) AddRulePeerMatch(ctx context.Context, arg AddRulePeerMatchParams) error
- func (q *Queries) AddRuleServiceEntry(ctx context.Context, arg AddRuleServiceEntryParams) error
- func (q *Queries) AddRuleServiceRef(ctx context.Context, arg AddRuleServiceRefParams) error
- func (q *Queries) AddRulesetScopeMatch(ctx context.Context, arg AddRulesetScopeMatchParams) error
- func (q *Queries) AddServiceEntry(ctx context.Context, arg AddServiceEntryParams) error
- func (q *Queries) AddWorkloadAddress(ctx context.Context, arg AddWorkloadAddressParams) error
- func (q *Queries) AddWorkloadLabel(ctx context.Context, arg AddWorkloadLabelParams) error
- func (q *Queries) AddWorkloadListeningService(ctx context.Context, arg AddWorkloadListeningServiceParams) error
- func (q *Queries) CountFlowWindows(ctx context.Context) (int64, error)
- func (q *Queries) CountRulesReferencingAddressGroup(ctx context.Context, addressGroupID *uuid.UUID) (int64, error)
- func (q *Queries) CountRulesReferencingService(ctx context.Context, serviceID uuid.UUID) (int64, error)
- func (q *Queries) CountWorkloadsByStatus(ctx context.Context) ([]CountWorkloadsByStatusRow, error)
- func (q *Queries) CreateAddressGroup(ctx context.Context, arg CreateAddressGroupParams) error
- func (q *Queries) CreateModeChange(ctx context.Context, arg CreateModeChangeParams) error
- func (q *Queries) CreateOperatorSession(ctx context.Context, arg CreateOperatorSessionParams) error
- func (q *Queries) CreateOperatorToken(ctx context.Context, arg CreateOperatorTokenParams) error
- func (q *Queries) CreateProvisioningToken(ctx context.Context, arg CreateProvisioningTokenParams) (ProvisioningToken, error)
- func (q *Queries) CreateRuleset(ctx context.Context, arg CreateRulesetParams) error
- func (q *Queries) CreateService(ctx context.Context, arg CreateServiceParams) error
- func (q *Queries) CreateWorkload(ctx context.Context, arg CreateWorkloadParams) error
- func (q *Queries) DeleteAddressGroup(ctx context.Context, arg DeleteAddressGroupParams) (int64, error)
- func (q *Queries) DeleteAddressGroupCIDRs(ctx context.Context, addressGroupID uuid.UUID) error
- func (q *Queries) DeleteExpiredOperatorSessions(ctx context.Context, now time.Time) (int64, error)
- func (q *Queries) DeleteFlowGapsBefore(ctx context.Context, arg DeleteFlowGapsBeforeParams) (int64, error)
- func (q *Queries) DeleteFlowWindowsBefore(ctx context.Context, arg DeleteFlowWindowsBeforeParams) (int64, error)
- func (q *Queries) DeleteOperatorSession(ctx context.Context, idHash []byte) (int64, error)
- func (q *Queries) DeleteRules(ctx context.Context, rulesetID uuid.UUID) error
- func (q *Queries) DeleteRuleset(ctx context.Context, arg DeleteRulesetParams) (int64, error)
- func (q *Queries) DeleteRulesetScopeMatches(ctx context.Context, rulesetID uuid.UUID) error
- func (q *Queries) DeleteService(ctx context.Context, arg DeleteServiceParams) (int64, error)
- func (q *Queries) DeleteServiceEntries(ctx context.Context, serviceID uuid.UUID) error
- func (q *Queries) DeleteWorkloadAddresses(ctx context.Context, workloadID uuid.UUID) error
- func (q *Queries) DeleteWorkloadLabels(ctx context.Context, workloadID uuid.UUID) error
- func (q *Queries) DeleteWorkloadListeningServices(ctx context.Context, workloadID uuid.UUID) error
- func (q *Queries) GetAddressGroup(ctx context.Context, id uuid.UUID) (AddressGroup, error)
- func (q *Queries) GetModeChange(ctx context.Context, id uuid.UUID) (ModeChange, error)
- func (q *Queries) GetOperator(ctx context.Context) (Operator, error)
- func (q *Queries) GetOperatorSession(ctx context.Context, idHash []byte) (OperatorSession, error)
- func (q *Queries) GetOperatorToken(ctx context.Context, id uuid.UUID) (OperatorToken, error)
- func (q *Queries) GetOperatorTokenByHash(ctx context.Context, tokenHash []byte) (OperatorToken, error)
- func (q *Queries) GetProvisioningToken(ctx context.Context, id uuid.UUID) (ProvisioningToken, error)
- func (q *Queries) GetProvisioningTokenByHash(ctx context.Context, tokenHash []byte) (ProvisioningToken, error)
- func (q *Queries) GetRuleset(ctx context.Context, id uuid.UUID) (Ruleset, error)
- func (q *Queries) GetService(ctx context.Context, id uuid.UUID) (Service, error)
- func (q *Queries) GetWorkload(ctx context.Context, id uuid.UUID) (Workload, error)
- func (q *Queries) GetWorkloadModes(ctx context.Context, workloadIds []uuid.UUID) ([]GetWorkloadModesRow, error)
- func (q *Queries) GetWorkloadPolicy(ctx context.Context, workloadID uuid.UUID) (WorkloadPolicy, error)
- func (q *Queries) GetWorkloadRetiredAt(ctx context.Context, id uuid.UUID) (*time.Time, error)
- func (q *Queries) GetWorkloadWithPolicy(ctx context.Context, id uuid.UUID) (GetWorkloadWithPolicyRow, error)
- func (q *Queries) InsertFlowGap(ctx context.Context, arg []InsertFlowGapParams) *InsertFlowGapBatchResults
- func (q *Queries) InsertFlowWindows(ctx context.Context, arg []InsertFlowWindowsParams) (int64, error)
- func (q *Queries) ListAddressGroupCIDRs(ctx context.Context, addressGroupID uuid.UUID) ([]AddressGroupCidr, error)
- func (q *Queries) ListAddressGroups(ctx context.Context) ([]AddressGroup, error)
- func (q *Queries) ListAllAddressGroupCIDRs(ctx context.Context) ([]AddressGroupCidr, error)
- func (q *Queries) ListAllProvisioningTokenLabels(ctx context.Context) ([]ProvisioningTokenLabel, error)
- func (q *Queries) ListAllRulePeerMatches(ctx context.Context) ([]RulePeerMatch, error)
- func (q *Queries) ListAllRulePeers(ctx context.Context) ([]RulePeer, error)
- func (q *Queries) ListAllRuleServiceEntries(ctx context.Context) ([]RuleServiceEntry, error)
- func (q *Queries) ListAllRuleServiceRefs(ctx context.Context) ([]RuleServiceRef, error)
- func (q *Queries) ListAllRules(ctx context.Context) ([]Rule, error)
- func (q *Queries) ListAllRulesetScopeMatches(ctx context.Context) ([]RulesetScopeMatch, error)
- func (q *Queries) ListAllServiceEntries(ctx context.Context) ([]ServiceEntry, error)
- func (q *Queries) ListAllWorkloadAddresses(ctx context.Context) ([]WorkloadAddress, error)
- func (q *Queries) ListAllWorkloadLabels(ctx context.Context) ([]WorkloadLabel, error)
- func (q *Queries) ListFlowGaps(ctx context.Context, arg ListFlowGapsParams) ([]FlowGap, error)
- func (q *Queries) ListFlowTotals(ctx context.Context, arg ListFlowTotalsParams) ([]FlowTotal, error)
- func (q *Queries) ListFlowWindowPage(ctx context.Context, arg ListFlowWindowPageParams) ([]FlowWindow, error)
- func (q *Queries) ListFlowWindows(ctx context.Context, arg ListFlowWindowsParams) ([]FlowWindow, error)
- func (q *Queries) ListModeChangeWorkloads(ctx context.Context, modeChangeID uuid.UUID) ([]ModeChangeWorkload, error)
- func (q *Queries) ListOperatorTokens(ctx context.Context) ([]OperatorToken, error)
- func (q *Queries) ListProvisioningTokenLabels(ctx context.Context, tokenID uuid.UUID) ([]ProvisioningTokenLabel, error)
- func (q *Queries) ListProvisioningTokens(ctx context.Context) ([]ProvisioningToken, error)
- func (q *Queries) ListRulesets(ctx context.Context) ([]Ruleset, error)
- func (q *Queries) ListServiceEntries(ctx context.Context, serviceID uuid.UUID) ([]ServiceEntry, error)
- func (q *Queries) ListServices(ctx context.Context) ([]Service, error)
- func (q *Queries) ListWorkloadAddresses(ctx context.Context, workloadID uuid.UUID) ([]string, error)
- func (q *Queries) ListWorkloadAddressesFor(ctx context.Context, workloadIds []uuid.UUID) ([]WorkloadAddress, error)
- func (q *Queries) ListWorkloadLabels(ctx context.Context, workloadID uuid.UUID) ([]WorkloadLabel, error)
- func (q *Queries) ListWorkloadLabelsFor(ctx context.Context, workloadIds []uuid.UUID) ([]WorkloadLabel, error)
- func (q *Queries) ListWorkloadListeningServices(ctx context.Context, workloadID uuid.UUID) ([]WorkloadListeningService, error)
- func (q *Queries) ListWorkloadListeningServicesFor(ctx context.Context, workloadIds []uuid.UUID) ([]WorkloadListeningService, error)
- func (q *Queries) ListWorkloadPage(ctx context.Context, arg ListWorkloadPageParams) ([]ListWorkloadPageRow, error)
- func (q *Queries) ListWorkloadPolicies(ctx context.Context) ([]WorkloadPolicy, error)
- func (q *Queries) ListWorkloads(ctx context.Context) ([]Workload, error)
- func (q *Queries) LockWorkload(ctx context.Context, id uuid.UUID) (LockWorkloadRow, error)
- func (q *Queries) NotifyDirective(ctx context.Context, arg NotifyDirectiveParams) error
- func (q *Queries) NotifyPolicyChanged(ctx context.Context, arg NotifyPolicyChangedParams) error
- func (q *Queries) Ping(ctx context.Context) (int32, error)
- func (q *Queries) RecordOperatorTokenUse(ctx context.Context, arg RecordOperatorTokenUseParams) error
- func (q *Queries) RecordProvisioningTokenUse(ctx context.Context, arg RecordProvisioningTokenUseParams) error
- func (q *Queries) RecordWorkloadAgent(ctx context.Context, arg RecordWorkloadAgentParams) (int64, error)
- func (q *Queries) RecordWorkloadApplied(ctx context.Context, arg RecordWorkloadAppliedParams) (int64, error)
- func (q *Queries) RecordWorkloadApplyFailed(ctx context.Context, arg RecordWorkloadApplyFailedParams) (int64, error)
- func (q *Queries) RecordWorkloadClockReading(ctx context.Context, arg RecordWorkloadClockReadingParams) error
- func (q *Queries) RecordWorkloadFlowReport(ctx context.Context, arg RecordWorkloadFlowReportParams) ([]RecordWorkloadFlowReportRow, error)
- func (q *Queries) RecordWorkloadHeartbeat(ctx context.Context, arg RecordWorkloadHeartbeatParams) (int64, error)
- func (q *Queries) RecordWorkloadHeartbeatSeen(ctx context.Context, arg RecordWorkloadHeartbeatSeenParams) (int64, error)
- func (q *Queries) RecordWorkloadInventory(ctx context.Context, arg RecordWorkloadInventoryParams) (int64, error)
- func (q *Queries) RecordWorkloadRenewal(ctx context.Context, arg RecordWorkloadRenewalParams) (int64, error)
- func (q *Queries) RecordWorkloadSnapshotSent(ctx context.Context, arg RecordWorkloadSnapshotSentParams) (int64, error)
- func (q *Queries) RetireWorkload(ctx context.Context, arg RetireWorkloadParams) (int64, error)
- func (q *Queries) RevokeOperatorToken(ctx context.Context, arg RevokeOperatorTokenParams) (int64, error)
- func (q *Queries) RevokeProvisioningToken(ctx context.Context, arg RevokeProvisioningTokenParams) (int64, error)
- func (q *Queries) RollupFlowWindows(ctx context.Context, arg RollupFlowWindowsParams) ([]RollupFlowWindowsRow, error)
- func (q *Queries) RollupFlowsByDstService(ctx context.Context, arg RollupFlowsByDstServiceParams) ([]RollupFlowsByDstServiceRow, error)
- func (q *Queries) RollupFlowsByPeerService(ctx context.Context, arg RollupFlowsByPeerServiceParams) ([]RollupFlowsByPeerServiceRow, error)
- func (q *Queries) RollupFlowsByRule(ctx context.Context, arg RollupFlowsByRuleParams) ([]RollupFlowsByRuleRow, error)
- func (q *Queries) RollupFlowsByRulePeer(ctx context.Context, arg RollupFlowsByRulePeerParams) ([]RollupFlowsByRulePeerRow, error)
- func (q *Queries) RollupFlowsBySrcDst(ctx context.Context, arg RollupFlowsBySrcDstParams) ([]RollupFlowsBySrcDstRow, error)
- func (q *Queries) SetOperator(ctx context.Context, arg SetOperatorParams) (Operator, error)
- func (q *Queries) SetWorkloadMode(ctx context.Context, arg SetWorkloadModeParams) (int64, error)
- func (q *Queries) SetWorkloadModes(ctx context.Context, arg SetWorkloadModesParams) (int64, error)
- func (q *Queries) SetWorkloadSyncState(ctx context.Context, arg SetWorkloadSyncStateParams) (int64, error)
- func (q *Queries) TryAcquireRetentionLock(ctx context.Context, key int64) (bool, error)
- func (q *Queries) UpdateAddressGroup(ctx context.Context, arg UpdateAddressGroupParams) (int64, error)
- func (q *Queries) UpdateRuleset(ctx context.Context, arg UpdateRulesetParams) (int64, error)
- func (q *Queries) UpdateService(ctx context.Context, arg UpdateServiceParams) (int64, error)
- func (q *Queries) UpsertFlowTotal(ctx context.Context, arg []UpsertFlowTotalParams) *UpsertFlowTotalBatchResults
- func (q *Queries) UpsertWorkloadPolicy(ctx context.Context, arg UpsertWorkloadPolicyParams) error
- func (q *Queries) WithTx(tx pgx.Tx) *Queries
- type RecordOperatorTokenUseParams
- type RecordProvisioningTokenUseParams
- type RecordWorkloadAgentParams
- type RecordWorkloadAppliedParams
- type RecordWorkloadApplyFailedParams
- type RecordWorkloadClockReadingParams
- type RecordWorkloadFlowReportParams
- type RecordWorkloadFlowReportRow
- type RecordWorkloadHeartbeatParams
- type RecordWorkloadHeartbeatSeenParams
- type RecordWorkloadInventoryParams
- type RecordWorkloadRenewalParams
- type RecordWorkloadSnapshotSentParams
- type RetireWorkloadParams
- type RevokeOperatorTokenParams
- type RevokeProvisioningTokenParams
- type RollupFlowWindowsParams
- type RollupFlowWindowsRow
- type RollupFlowsByDstServiceParams
- type RollupFlowsByDstServiceRow
- type RollupFlowsByPeerServiceParams
- type RollupFlowsByPeerServiceRow
- type RollupFlowsByRuleParams
- type RollupFlowsByRulePeerParams
- type RollupFlowsByRulePeerRow
- type RollupFlowsByRuleRow
- type RollupFlowsBySrcDstParams
- type RollupFlowsBySrcDstRow
- type Rule
- type RulePeer
- type RulePeerMatch
- type RuleServiceEntry
- type RuleServiceRef
- type Ruleset
- type RulesetScopeMatch
- type Service
- type ServiceEntry
- type SetOperatorParams
- type SetWorkloadModeParams
- type SetWorkloadModesParams
- type SetWorkloadSyncStateParams
- type UpdateAddressGroupParams
- type UpdateRulesetParams
- type UpdateServiceParams
- type UpsertFlowTotalBatchResults
- type UpsertFlowTotalParams
- type UpsertWorkloadPolicyParams
- type Workload
- type WorkloadAddress
- type WorkloadLabel
- type WorkloadListeningService
- type WorkloadPolicy
Constants ¶
This section is empty.
Variables ¶
var (
ErrBatchAlreadyClosed = errors.New("batch already closed")
)
Functions ¶
This section is empty.
Types ¶
type AddRuleParams ¶
type AddRulePeerMatchParams ¶
type AddRulePeerParams ¶
type AddRuleServiceRefParams ¶
type AddServiceEntryParams ¶
type AddWorkloadLabelParams ¶
type AddressGroup ¶
type AddressGroupCidr ¶
type CountWorkloadsByStatusRow ¶ added in v0.2.0
type CreateModeChangeParams ¶
type CreateRulesetParams ¶
type CreateServiceParams ¶
type CreateWorkloadParams ¶
type DBTX ¶
type DBTX interface {
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
QueryRow(context.Context, string, ...interface{}) pgx.Row
CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
SendBatch(context.Context, *pgx.Batch) pgx.BatchResults
}
type DeleteRulesetParams ¶
type DeleteServiceParams ¶
type FlowWindow ¶
type FlowWindow struct {
ID int64
RegionID string
WorkloadID uuid.UUID
WindowStart time.Time
WindowEnd time.Time
PeerKind int32
PeerKey string
PeerLabels []byte
SrcAddress string
DstAddress string
DstPort int32
Protocol int32
Direction int32
Decision int32
MatchedRuleID string
ConnectionCount int64
ByteCount int64
FirstSeen time.Time
LastSeen time.Time
ProcessName string
}
type GetWorkloadModesRow ¶
type InsertFlowGapBatchResults ¶
type InsertFlowGapBatchResults struct {
// contains filtered or unexported fields
}
func (*InsertFlowGapBatchResults) Close ¶
func (b *InsertFlowGapBatchResults) Close() error
func (*InsertFlowGapBatchResults) Exec ¶
func (b *InsertFlowGapBatchResults) Exec(f func(int, error))
type InsertFlowGapParams ¶
type InsertFlowWindowsParams ¶
type InsertFlowWindowsParams struct {
WorkloadID uuid.UUID
WindowStart time.Time
WindowEnd time.Time
PeerKind int32
PeerKey string
PeerLabels []byte
SrcAddress string
DstAddress string
DstPort int32
Protocol int32
Direction int32
Decision int32
MatchedRuleID string
ConnectionCount int64
ByteCount int64
FirstSeen time.Time
LastSeen time.Time
ProcessName string
}
type ListFlowGapsParams ¶
type ListFlowTotalsParams ¶
type ListFlowWindowsParams ¶
type ListWorkloadPageParams ¶
type ListWorkloadPageRow ¶
type ListWorkloadPageRow struct {
ID uuid.UUID
RegionID string
ProvisioningTokenID uuid.UUID
Hostname string
EnrolledAt time.Time
CredentialSerial string
CredentialExpiresAt time.Time
LastRenewedAt *time.Time
Mode int32
Facts []byte
AgentVersion string
AgentCapabilities []string
LastSeenAt *time.Time
SyncState int32
AppliedPolicyVersion int64
SyncError string
DroppedFlowRecords int64
CredentialRenewalError string
LastSnapshotSentAt *time.Time
LastAckedAt *time.Time
LastApplyFailedAt *time.Time
SourceOverruns int64
ClockSkewOffsetMs pgtype.Int8
ClockSkewObservedAt *time.Time
ClockSkewCurrent bool
OwnedTableState int16
OwnedTableAbsentSince *time.Time
LastFlowReportAt *time.Time
LateRenewalAt *time.Time
LateRenewalExpiredAt *time.Time
RetiredAt *time.Time
PresentedCredentialSerial *string
PresentedCredentialExpiresAt *time.Time
SyncRank int32
SeenKey time.Time
LatestVersion pgtype.Int8
LatestRenderedAt *time.Time
}
type LockWorkloadRow ¶ added in v0.5.0
type ModeChange ¶
type ModeChangeWorkload ¶
type NotifyDirectiveParams ¶
type OperatorSession ¶
type OperatorToken ¶
type ProvisioningToken ¶
type ProvisioningTokenLabel ¶
type Querier ¶
type Querier interface {
// Rendered per-workload policy and its version (ADR-0018). The render
// transaction holds an advisory lock so that two renders never interleave
// their version bumps, and it notifies listeners of every changed workload
// on commit so that the replica holding the workload's stream pushes the
// change without anything polling (ADR-0002).
AcquireRenderLock(ctx context.Context, key int64) error
AddAddressGroupCIDR(ctx context.Context, arg AddAddressGroupCIDRParams) error
AddModeChangeWorkload(ctx context.Context, arg AddModeChangeWorkloadParams) error
AddProvisioningTokenLabel(ctx context.Context, arg AddProvisioningTokenLabelParams) error
AddRule(ctx context.Context, arg AddRuleParams) error
AddRulePeer(ctx context.Context, arg AddRulePeerParams) error
AddRulePeerMatch(ctx context.Context, arg AddRulePeerMatchParams) error
AddRuleServiceEntry(ctx context.Context, arg AddRuleServiceEntryParams) error
AddRuleServiceRef(ctx context.Context, arg AddRuleServiceRefParams) error
AddRulesetScopeMatch(ctx context.Context, arg AddRulesetScopeMatchParams) error
AddServiceEntry(ctx context.Context, arg AddServiceEntryParams) error
AddWorkloadAddress(ctx context.Context, arg AddWorkloadAddressParams) error
AddWorkloadLabel(ctx context.Context, arg AddWorkloadLabelParams) error
AddWorkloadListeningService(ctx context.Context, arg AddWorkloadListeningServiceParams) error
CountFlowWindows(ctx context.Context) (int64, error)
CountRulesReferencingAddressGroup(ctx context.Context, addressGroupID *uuid.UUID) (int64, error)
CountRulesReferencingService(ctx context.Context, serviceID uuid.UUID) (int64, error)
// How many workloads hold each sync state, split by whether their owned
// table is recorded absent (migration 00012) and by whether they are
// retired (ADR-0023), in one statement so the counts agree with each
// other. A combination no workload holds has no row.
CountWorkloadsByStatus(ctx context.Context) ([]CountWorkloadsByStatusRow, error)
// Address groups: named CIDR sets for peers that are not managed workloads
// (ADR-0018).
CreateAddressGroup(ctx context.Context, arg CreateAddressGroupParams) error
// Recorded bulk mode changes (ADR-0007 as amended): the intent as
// submitted, the set it resolved to, and what changed. Written inside the
// render transaction that flips the modes, so the record and the flip are
// one unit.
CreateModeChange(ctx context.Context, arg CreateModeChangeParams) error
CreateOperatorSession(ctx context.Context, arg CreateOperatorSessionParams) error
CreateOperatorToken(ctx context.Context, arg CreateOperatorTokenParams) error
// Provisioning tokens (ADR-0016 as amended). A token is looked up only by
// its SHA-256 hash; beside it only token_prefix, the listing hint, is kept,
// NULL for tokens minted before it was. No query here touches plaintext.
CreateProvisioningToken(ctx context.Context, arg CreateProvisioningTokenParams) (ProvisioningToken, error)
// Rulesets and their rules: the authored policy model (ADR-0018). A ruleset
// is written and replaced as a unit; its child rows are deleted and
// reinserted inside one transaction on update.
CreateRuleset(ctx context.Context, arg CreateRulesetParams) error
// Named service definitions: reusable protocol/port sets (ADR-0018).
CreateService(ctx context.Context, arg CreateServiceParams) error
// Workload identity registry (ADR-0016). The id column is the workload_id
// carried in the credential's URI SAN; labels are assigned at enrollment from
// the provisioning token's scope and are never read from a certificate.
CreateWorkload(ctx context.Context, arg CreateWorkloadParams) error
DeleteAddressGroup(ctx context.Context, arg DeleteAddressGroupParams) (int64, error)
DeleteAddressGroupCIDRs(ctx context.Context, addressGroupID uuid.UUID) error
// Retention: expired sessions are removed on the same schedule as aged
// flow windows (ADR-0019, ADR-0021).
DeleteExpiredOperatorSessions(ctx context.Context, now time.Time) (int64, error)
// Retention: one bounded batch of the gaps that ended before the horizon,
// so a gap outlives every window it could describe.
DeleteFlowGapsBefore(ctx context.Context, arg DeleteFlowGapsBeforeParams) (int64, error)
// Retention: one bounded batch of the oldest windows before the horizon.
// The caller loops until a batch deletes nothing, so no single statement
// holds locks for the whole backlog (ADR-0019).
DeleteFlowWindowsBefore(ctx context.Context, arg DeleteFlowWindowsBeforeParams) (int64, error)
DeleteOperatorSession(ctx context.Context, idHash []byte) (int64, error)
DeleteRules(ctx context.Context, rulesetID uuid.UUID) error
DeleteRuleset(ctx context.Context, arg DeleteRulesetParams) (int64, error)
DeleteRulesetScopeMatches(ctx context.Context, rulesetID uuid.UUID) error
DeleteService(ctx context.Context, arg DeleteServiceParams) (int64, error)
DeleteServiceEntries(ctx context.Context, serviceID uuid.UUID) error
DeleteWorkloadAddresses(ctx context.Context, workloadID uuid.UUID) error
DeleteWorkloadLabels(ctx context.Context, workloadID uuid.UUID) error
DeleteWorkloadListeningServices(ctx context.Context, workloadID uuid.UUID) error
GetAddressGroup(ctx context.Context, id uuid.UUID) (AddressGroup, error)
GetModeChange(ctx context.Context, id uuid.UUID) (ModeChange, error)
// Operator surface (ADR-0021). Passwords are stored as argon2id strings;
// session identifiers and operator tokens only as SHA-256 digests. No query
// here touches a plaintext credential.
GetOperator(ctx context.Context) (Operator, error)
GetOperatorSession(ctx context.Context, idHash []byte) (OperatorSession, error)
GetOperatorToken(ctx context.Context, id uuid.UUID) (OperatorToken, error)
GetOperatorTokenByHash(ctx context.Context, tokenHash []byte) (OperatorToken, error)
GetProvisioningToken(ctx context.Context, id uuid.UUID) (ProvisioningToken, error)
GetProvisioningTokenByHash(ctx context.Context, tokenHash []byte) (ProvisioningToken, error)
GetRuleset(ctx context.Context, id uuid.UUID) (Ruleset, error)
GetService(ctx context.Context, id uuid.UUID) (Service, error)
GetWorkload(ctx context.Context, id uuid.UUID) (Workload, error)
// The modes of a resolved set before it is flipped, and the flip itself,
// by explicit id: the set was resolved once, in this transaction, and a
// label change committed meanwhile does not move it.
GetWorkloadModes(ctx context.Context, workloadIds []uuid.UUID) ([]GetWorkloadModesRow, error)
GetWorkloadPolicy(ctx context.Context, workloadID uuid.UUID) (WorkloadPolicy, error)
// Why a conditioned write found no row: absent, or retired since when.
GetWorkloadRetiredAt(ctx context.Context, id uuid.UUID) (*time.Time, error)
// One workload with its latest rendered version, for the detail read.
GetWorkloadWithPolicy(ctx context.Context, id uuid.UUID) (GetWorkloadWithPolicyRow, error)
// --- evidence gaps -------------------------------------------------------------
//
// Intervals in which a workload's evidence is known to be incomplete
// (ADR-0019 as amended). Delivery is at least once: an interval repeated
// exactly is stored once.
InsertFlowGap(ctx context.Context, arg []InsertFlowGapParams) *InsertFlowGapBatchResults
// Flow storage (ADR-0009, ADR-0019). These are the only statements that
// touch flow_windows, flow_totals, and flow_gaps; every caller goes through
// the FlowStore interface in internal/flowstore.
InsertFlowWindows(ctx context.Context, arg []InsertFlowWindowsParams) (int64, error)
ListAddressGroupCIDRs(ctx context.Context, addressGroupID uuid.UUID) ([]AddressGroupCidr, error)
ListAddressGroups(ctx context.Context) ([]AddressGroup, error)
ListAllAddressGroupCIDRs(ctx context.Context) ([]AddressGroupCidr, error)
ListAllProvisioningTokenLabels(ctx context.Context) ([]ProvisioningTokenLabel, error)
ListAllRulePeerMatches(ctx context.Context) ([]RulePeerMatch, error)
ListAllRulePeers(ctx context.Context) ([]RulePeer, error)
ListAllRuleServiceEntries(ctx context.Context) ([]RuleServiceEntry, error)
ListAllRuleServiceRefs(ctx context.Context) ([]RuleServiceRef, error)
ListAllRules(ctx context.Context) ([]Rule, error)
ListAllRulesetScopeMatches(ctx context.Context) ([]RulesetScopeMatch, error)
ListAllServiceEntries(ctx context.Context) ([]ServiceEntry, error)
ListAllWorkloadAddresses(ctx context.Context) ([]WorkloadAddress, error)
ListAllWorkloadLabels(ctx context.Context) ([]WorkloadLabel, error)
// The gaps of a workload set that intersect [since, until): a gap
// [gap_from, gap_to) intersects it when it starts before the range ends
// and ends after the range starts; an instantaneous gap intersects when
// its instant lies in the range. Newest first, bounded; an empty workload
// id array means every workload.
ListFlowGaps(ctx context.Context, arg ListFlowGapsParams) ([]FlowGap, error)
ListFlowTotals(ctx context.Context, arg ListFlowTotalsParams) ([]FlowTotal, error)
// One page of a workload's windows, newest first, keyed by
// (window_start, id) so a page never shifts when new windows land. The
// first page passes a cursor beyond any row. An empty peer key means every
// peer; a zero protocol means every service.
ListFlowWindowPage(ctx context.Context, arg ListFlowWindowPageParams) ([]FlowWindow, error)
ListFlowWindows(ctx context.Context, arg ListFlowWindowsParams) ([]FlowWindow, error)
ListModeChangeWorkloads(ctx context.Context, modeChangeID uuid.UUID) ([]ModeChangeWorkload, error)
ListOperatorTokens(ctx context.Context) ([]OperatorToken, error)
ListProvisioningTokenLabels(ctx context.Context, tokenID uuid.UUID) ([]ProvisioningTokenLabel, error)
ListProvisioningTokens(ctx context.Context) ([]ProvisioningToken, error)
ListRulesets(ctx context.Context) ([]Ruleset, error)
ListServiceEntries(ctx context.Context, serviceID uuid.UUID) ([]ServiceEntry, error)
ListServices(ctx context.Context) ([]Service, error)
ListWorkloadAddresses(ctx context.Context, workloadID uuid.UUID) ([]string, error)
ListWorkloadAddressesFor(ctx context.Context, workloadIds []uuid.UUID) ([]WorkloadAddress, error)
ListWorkloadLabels(ctx context.Context, workloadID uuid.UUID) ([]WorkloadLabel, error)
// The children of the workloads on one page, fetched once per page.
ListWorkloadLabelsFor(ctx context.Context, workloadIds []uuid.UUID) ([]WorkloadLabel, error)
ListWorkloadListeningServices(ctx context.Context, workloadID uuid.UUID) ([]WorkloadListeningService, error)
ListWorkloadListeningServicesFor(ctx context.Context, workloadIds []uuid.UUID) ([]WorkloadListeningService, error)
// --- operator read model (ADR-0007 as amended) -------------------------------
// One page of the fleet in the order the fleet screen shows it: the
// workloads needing attention first (degraded or enforcement removed,
// then offline, then pending, then synced), most recently seen first
// within a rank, then by id. A workload whose owned table is recorded
// absent (migration 00012) ranks with the degraded ones whatever its
// stored sync state, which stays the agent's honest record (issue #96). The cursor is the (rank, last seen, id) of the last row served; the
// first page passes a rank below every row. A workload never seen sorts
// as if seen at the epoch. An empty id array means every workload; a zero
// mode or sync state means any. The latest rendered version rides along
// from workload_policies so sync drift is one read.
//
// A retired workload is outside the attention ordering (ADR-0023): the
// lifecycle argument selects active workloads (1) or retired ones (2),
// never both, and a retired one takes a rank of its own below every
// other with its retirement instant as the sort key, so the retired list
// runs most recently retired first through the same cursor.
ListWorkloadPage(ctx context.Context, arg ListWorkloadPageParams) ([]ListWorkloadPageRow, error)
ListWorkloadPolicies(ctx context.Context) ([]WorkloadPolicy, error)
// --- inventory and status (ADR-0018) ------------------------------------------
ListWorkloads(ctx context.Context) ([]Workload, error)
// --- retirement (ADR-0023) ----------------------------------------------------
// The row a retirement or a label write locks before it reads, so the two
// serialize with each other and with flow ingest's receipt: the instant it
// was retired (NULL while active), and what the silence derivation reads,
// the last report's receipt and the latest heartbeat's pair.
LockWorkload(ctx context.Context, id uuid.UUID) (LockWorkloadRow, error)
// A directive for the stream of one workload rides the same channel as
// render announcements, keyed by the workload; the replica holding that
// stream, if any, sends it (ADR-0018 as amended). It is sent outside any
// transaction, so it is delivered at once.
NotifyDirective(ctx context.Context, arg NotifyDirectiveParams) error
NotifyPolicyChanged(ctx context.Context, arg NotifyPolicyChangedParams) error
// Queries are hand-written SQL compiled by sqlc into internal/store/db
// (ADR-0006). One file per concern; every production query lives here.
//
// Ping is a connectivity probe that touches no tables. It exists so the data
// layer is exercised end to end before the first migration lands.
Ping(ctx context.Context) (int32, error)
RecordOperatorTokenUse(ctx context.Context, arg RecordOperatorTokenUseParams) error
RecordProvisioningTokenUse(ctx context.Context, arg RecordProvisioningTokenUseParams) error
// The Hello also stamps the credential the stream opened on (migration
// 00018); a caller that knows of none passes both NULL and leaves the
// stamp as it was, so the pair is never half-written or made up.
RecordWorkloadAgent(ctx context.Context, arg RecordWorkloadAgentParams) (int64, error)
// An APPLIED acknowledgement: the version, the resulting state, and the
// instant. Nothing else writes last_acked_at (migration 00007). An apply
// that succeeded installed the owned table, so a table recorded absent is
// present again (migration 00012).
RecordWorkloadApplied(ctx context.Context, arg RecordWorkloadAppliedParams) (int64, error)
// A FAILED acknowledgement: the degraded state, the agent's detail, and the
// instant. The applied version is untouched; the agent is still on it.
// Nothing else writes last_apply_failed_at (migration 00007).
RecordWorkloadApplyFailed(ctx context.Context, arg RecordWorkloadApplyFailedParams) (int64, error)
// One flow report's reading of the agent's clock (migration 00010). A
// skewed reading records its offset and instant and marks the skew current;
// a reading within tolerance only clears the mark, and writes nothing when
// there is no mark to clear, so a healthy agent's reports cost no write.
RecordWorkloadClockReading(ctx context.Context, arg RecordWorkloadClockReadingParams) error
// The receipt of one flow report (migration 00013). Never moved backwards,
// so reports handled out of order across replicas leave the latest. The
// row it replaces comes back so ingest can derive the agent-silence gap
// (migration 00015): the locking subquery serializes concurrent reports of
// one workload, so each silence is seen by exactly one of them. The latest
// heartbeat's receipt and process start ride along, read under the same
// lock, so the derivation can tell a quiet agent from an absent one
// (migration 00016). No row means the receipt did not advance (a stale
// report, or no such workload). A retired workload's receipt never moves:
// its retirement closed the silence the receipt would bound, under the same
// row lock, so a report racing it derives nothing twice (ADR-0023).
RecordWorkloadFlowReport(ctx context.Context, arg RecordWorkloadFlowReportParams) ([]RecordWorkloadFlowReportRow, error)
// A heartbeat's counters, renewal status, and owned-table state (migration
// 00012). An unknown state leaves the stored one; the absent instant is the
// first heartbeat's that said absent, kept while the state stays absent.
// The heartbeat's receipt and the start of the process it came from are
// written together, so the pair is always one heartbeat's (migration 00016).
RecordWorkloadHeartbeat(ctx context.Context, arg RecordWorkloadHeartbeatParams) (int64, error)
RecordWorkloadHeartbeatSeen(ctx context.Context, arg RecordWorkloadHeartbeatSeenParams) (int64, error)
// The writes a sync stream makes from what its agent sends (inventory,
// Hello, heartbeats, acknowledgements) are conditioned on the workload not
// being retired: no row means it is unknown or retired, and the stream of a
// retired workload ends at the next one (ADR-0023).
RecordWorkloadInventory(ctx context.Context, arg RecordWorkloadInventoryParams) (int64, error)
// A late renewal (one made with an already-expired credential, within the
// grace) also replaces the workload's late-renewal record; an on-time one
// leaves it (ADR-0016 as amended).
// A retired workload renews nothing (ADR-0023): the write is conditioned
// on it, so a retirement committed after the renewal was admitted still
// refuses it here.
RecordWorkloadRenewal(ctx context.Context, arg RecordWorkloadRenewalParams) (int64, error)
// Stamped by the sync path whenever it sends the workload a snapshot,
// whatever caused it; nothing else writes it (ADR-0018 as amended).
RecordWorkloadSnapshotSent(ctx context.Context, arg RecordWorkloadSnapshotSentParams) (int64, error)
// Retirement stamps the instant once; nothing clears it.
RetireWorkload(ctx context.Context, arg RetireWorkloadParams) (int64, error)
RevokeOperatorToken(ctx context.Context, arg RevokeOperatorTokenParams) (int64, error)
RevokeProvisioningToken(ctx context.Context, arg RevokeProvisioningTokenParams) (int64, error)
// The rollup the operator console issues for a label scope: the scope is
// resolved to workload ids by the caller, and the rows are grouped by
// resolved peer and service (destination port and protocol). A decision of
// 0 means every decision.
RollupFlowWindows(ctx context.Context, arg RollupFlowWindowsParams) ([]RollupFlowWindowsRow, error)
// Grouped by the reporting workload and the service reached on it: the
// cells of the matrix.
RollupFlowsByDstService(ctx context.Context, arg RollupFlowsByDstServiceParams) ([]RollupFlowsByDstServiceRow, error)
// Grouped by the resolved peer and the service it reached, across every
// workload in scope, with the number of distinct workloads that saw it:
// the rows of a simulation review (ADR-0019 decision 4(b)). The label
// snapshot of a peer is the one stored with its most recently seen
// record.
RollupFlowsByPeerService(ctx context.Context, arg RollupFlowsByPeerServiceParams) ([]RollupFlowsByPeerServiceRow, error)
// --- operator read model -----------------------------------------------------
//
// The rollups the operator surface and the command line issue (ADR-0007 as
// amended, ADR-0019 decision 4). Each grouping the surface offers is one
// named statement over the same windows; the caller picks the statement
// and never assembles one. Every rollup shares one filter convention: an
// empty workload id array means every workload; a non-empty one selects
// the records those workloads reported, and with either_endpoint also the
// records whose source resolved at ingest to one of them (peer kind 1, a
// workload, keyed by its id), each record once; a zero decision or
// direction means any, and a zero protocol means every service (a service
// is one destination port and protocol). Ordering is by connection count
// unless order_by is 'recent', in which case the most recently seen group
// comes first. The window bounds actually covered, the number of groups,
// and the totals across every group ride on each row as window aggregates,
// so a truncated result still says how it relates to the whole. The
// decision-and-time and workload-and-time indexes serve all five.
// Grouped by the resolved rule that admitted the traffic; records with no
// matched rule form the group with the empty rule id. Each group counts
// the distinct workloads that reported it, since a rule's key names none.
RollupFlowsByRule(ctx context.Context, arg RollupFlowsByRuleParams) ([]RollupFlowsByRuleRow, error)
// Grouped by rule and the resolved peer that hit it. The label snapshot
// of a peer is the one stored with its most recently seen record.
RollupFlowsByRulePeer(ctx context.Context, arg RollupFlowsByRulePeerParams) ([]RollupFlowsByRulePeerRow, error)
// Grouped by the resolved source peer and the reporting workload: the
// edges of the dependency map. Inbound only in this version, so the
// source is the peer and the destination is the workload.
RollupFlowsBySrcDst(ctx context.Context, arg RollupFlowsBySrcDstParams) ([]RollupFlowsBySrcDstRow, error)
SetOperator(ctx context.Context, arg SetOperatorParams) (Operator, error)
SetWorkloadMode(ctx context.Context, arg SetWorkloadModeParams) (int64, error)
SetWorkloadModes(ctx context.Context, arg SetWorkloadModesParams) (int64, error)
SetWorkloadSyncState(ctx context.Context, arg SetWorkloadSyncStateParams) (int64, error)
// Retention runs singly across replicas: whichever replica acquires the
// lock prunes, the others skip this round (ADR-0017).
TryAcquireRetentionLock(ctx context.Context, key int64) (bool, error)
// Conditional writes: expected is the version token the caller last read,
// compared byte-exact against the stored version's decimal form, or NULL
// for an unconditional write. Every write advances the version by one.
UpdateAddressGroup(ctx context.Context, arg UpdateAddressGroupParams) (int64, error)
// A conditional write: expected is the version token the caller last
// read, compared byte-exact against the stored version's decimal form, or
// NULL for an unconditional write (the command line's default). Every
// write advances the version by one and returns it. No row with a NULL
// expected means the ruleset does not exist; no row with one set means
// either that or a version the caller did not see.
UpdateRuleset(ctx context.Context, arg UpdateRulesetParams) (int64, error)
// Conditional writes: expected is the version token the caller last read,
// compared byte-exact against the stored version's decimal form, or NULL
// for an unconditional write. Every write advances the version by one.
UpdateService(ctx context.Context, arg UpdateServiceParams) (int64, error)
UpsertFlowTotal(ctx context.Context, arg []UpsertFlowTotalParams) *UpsertFlowTotalBatchResults
UpsertWorkloadPolicy(ctx context.Context, arg UpsertWorkloadPolicyParams) error
}
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) AcquireRenderLock ¶
Rendered per-workload policy and its version (ADR-0018). The render transaction holds an advisory lock so that two renders never interleave their version bumps, and it notifies listeners of every changed workload on commit so that the replica holding the workload's stream pushes the change without anything polling (ADR-0002).
func (*Queries) AddAddressGroupCIDR ¶
func (q *Queries) AddAddressGroupCIDR(ctx context.Context, arg AddAddressGroupCIDRParams) error
func (*Queries) AddModeChangeWorkload ¶
func (q *Queries) AddModeChangeWorkload(ctx context.Context, arg AddModeChangeWorkloadParams) error
func (*Queries) AddProvisioningTokenLabel ¶
func (q *Queries) AddProvisioningTokenLabel(ctx context.Context, arg AddProvisioningTokenLabelParams) error
func (*Queries) AddRulePeer ¶
func (q *Queries) AddRulePeer(ctx context.Context, arg AddRulePeerParams) error
func (*Queries) AddRulePeerMatch ¶
func (q *Queries) AddRulePeerMatch(ctx context.Context, arg AddRulePeerMatchParams) error
func (*Queries) AddRuleServiceEntry ¶
func (q *Queries) AddRuleServiceEntry(ctx context.Context, arg AddRuleServiceEntryParams) error
func (*Queries) AddRuleServiceRef ¶
func (q *Queries) AddRuleServiceRef(ctx context.Context, arg AddRuleServiceRefParams) error
func (*Queries) AddRulesetScopeMatch ¶
func (q *Queries) AddRulesetScopeMatch(ctx context.Context, arg AddRulesetScopeMatchParams) error
func (*Queries) AddServiceEntry ¶
func (q *Queries) AddServiceEntry(ctx context.Context, arg AddServiceEntryParams) error
func (*Queries) AddWorkloadAddress ¶
func (q *Queries) AddWorkloadAddress(ctx context.Context, arg AddWorkloadAddressParams) error
func (*Queries) AddWorkloadLabel ¶
func (q *Queries) AddWorkloadLabel(ctx context.Context, arg AddWorkloadLabelParams) error
func (*Queries) AddWorkloadListeningService ¶
func (q *Queries) AddWorkloadListeningService(ctx context.Context, arg AddWorkloadListeningServiceParams) error
func (*Queries) CountFlowWindows ¶
func (*Queries) CountRulesReferencingAddressGroup ¶
func (*Queries) CountRulesReferencingService ¶
func (*Queries) CountWorkloadsByStatus ¶ added in v0.2.0
func (q *Queries) CountWorkloadsByStatus(ctx context.Context) ([]CountWorkloadsByStatusRow, error)
How many workloads hold each sync state, split by whether their owned table is recorded absent (migration 00012) and by whether they are retired (ADR-0023), in one statement so the counts agree with each other. A combination no workload holds has no row.
func (*Queries) CreateAddressGroup ¶
func (q *Queries) CreateAddressGroup(ctx context.Context, arg CreateAddressGroupParams) error
Address groups: named CIDR sets for peers that are not managed workloads (ADR-0018).
func (*Queries) CreateModeChange ¶
func (q *Queries) CreateModeChange(ctx context.Context, arg CreateModeChangeParams) error
Recorded bulk mode changes (ADR-0007 as amended): the intent as submitted, the set it resolved to, and what changed. Written inside the render transaction that flips the modes, so the record and the flip are one unit.
func (*Queries) CreateOperatorSession ¶
func (q *Queries) CreateOperatorSession(ctx context.Context, arg CreateOperatorSessionParams) error
func (*Queries) CreateOperatorToken ¶
func (q *Queries) CreateOperatorToken(ctx context.Context, arg CreateOperatorTokenParams) error
func (*Queries) CreateProvisioningToken ¶
func (q *Queries) CreateProvisioningToken(ctx context.Context, arg CreateProvisioningTokenParams) (ProvisioningToken, error)
Provisioning tokens (ADR-0016 as amended). A token is looked up only by its SHA-256 hash; beside it only token_prefix, the listing hint, is kept, NULL for tokens minted before it was. No query here touches plaintext.
func (*Queries) CreateRuleset ¶
func (q *Queries) CreateRuleset(ctx context.Context, arg CreateRulesetParams) error
Rulesets and their rules: the authored policy model (ADR-0018). A ruleset is written and replaced as a unit; its child rows are deleted and reinserted inside one transaction on update.
func (*Queries) CreateService ¶
func (q *Queries) CreateService(ctx context.Context, arg CreateServiceParams) error
Named service definitions: reusable protocol/port sets (ADR-0018).
func (*Queries) CreateWorkload ¶
func (q *Queries) CreateWorkload(ctx context.Context, arg CreateWorkloadParams) error
Workload identity registry (ADR-0016). The id column is the workload_id carried in the credential's URI SAN; labels are assigned at enrollment from the provisioning token's scope and are never read from a certificate.
func (*Queries) DeleteAddressGroup ¶
func (*Queries) DeleteAddressGroupCIDRs ¶
func (*Queries) DeleteExpiredOperatorSessions ¶
Retention: expired sessions are removed on the same schedule as aged flow windows (ADR-0019, ADR-0021).
func (*Queries) DeleteFlowGapsBefore ¶
func (q *Queries) DeleteFlowGapsBefore(ctx context.Context, arg DeleteFlowGapsBeforeParams) (int64, error)
Retention: one bounded batch of the gaps that ended before the horizon, so a gap outlives every window it could describe.
func (*Queries) DeleteFlowWindowsBefore ¶
func (q *Queries) DeleteFlowWindowsBefore(ctx context.Context, arg DeleteFlowWindowsBeforeParams) (int64, error)
Retention: one bounded batch of the oldest windows before the horizon. The caller loops until a batch deletes nothing, so no single statement holds locks for the whole backlog (ADR-0019).
func (*Queries) DeleteOperatorSession ¶
func (*Queries) DeleteRules ¶
func (*Queries) DeleteRuleset ¶
func (*Queries) DeleteRulesetScopeMatches ¶
func (*Queries) DeleteService ¶
func (*Queries) DeleteServiceEntries ¶
func (*Queries) DeleteWorkloadAddresses ¶
func (*Queries) DeleteWorkloadLabels ¶
func (*Queries) DeleteWorkloadListeningServices ¶
func (*Queries) GetAddressGroup ¶
func (*Queries) GetModeChange ¶
func (*Queries) GetOperator ¶
Operator surface (ADR-0021). Passwords are stored as argon2id strings; session identifiers and operator tokens only as SHA-256 digests. No query here touches a plaintext credential.
func (*Queries) GetOperatorSession ¶
func (*Queries) GetOperatorToken ¶
func (*Queries) GetOperatorTokenByHash ¶
func (*Queries) GetProvisioningToken ¶
func (*Queries) GetProvisioningTokenByHash ¶
func (*Queries) GetRuleset ¶
func (*Queries) GetService ¶
func (*Queries) GetWorkload ¶
func (*Queries) GetWorkloadModes ¶
func (q *Queries) GetWorkloadModes(ctx context.Context, workloadIds []uuid.UUID) ([]GetWorkloadModesRow, error)
The modes of a resolved set before it is flipped, and the flip itself, by explicit id: the set was resolved once, in this transaction, and a label change committed meanwhile does not move it.
func (*Queries) GetWorkloadPolicy ¶
func (*Queries) GetWorkloadRetiredAt ¶ added in v0.5.0
Why a conditioned write found no row: absent, or retired since when.
func (*Queries) GetWorkloadWithPolicy ¶
func (q *Queries) GetWorkloadWithPolicy(ctx context.Context, id uuid.UUID) (GetWorkloadWithPolicyRow, error)
One workload with its latest rendered version, for the detail read.
func (*Queries) InsertFlowGap ¶
func (q *Queries) InsertFlowGap(ctx context.Context, arg []InsertFlowGapParams) *InsertFlowGapBatchResults
--- evidence gaps -------------------------------------------------------------
Intervals in which a workload's evidence is known to be incomplete (ADR-0019 as amended). Delivery is at least once: an interval repeated exactly is stored once.
func (*Queries) InsertFlowWindows ¶
func (q *Queries) InsertFlowWindows(ctx context.Context, arg []InsertFlowWindowsParams) (int64, error)
Flow storage (ADR-0009, ADR-0019). These are the only statements that touch flow_windows, flow_totals, and flow_gaps; every caller goes through the FlowStore interface in internal/flowstore.
func (*Queries) ListAddressGroupCIDRs ¶
func (*Queries) ListAddressGroups ¶
func (q *Queries) ListAddressGroups(ctx context.Context) ([]AddressGroup, error)
func (*Queries) ListAllAddressGroupCIDRs ¶
func (q *Queries) ListAllAddressGroupCIDRs(ctx context.Context) ([]AddressGroupCidr, error)
func (*Queries) ListAllProvisioningTokenLabels ¶
func (q *Queries) ListAllProvisioningTokenLabels(ctx context.Context) ([]ProvisioningTokenLabel, error)
func (*Queries) ListAllRulePeerMatches ¶
func (q *Queries) ListAllRulePeerMatches(ctx context.Context) ([]RulePeerMatch, error)
func (*Queries) ListAllRulePeers ¶
func (*Queries) ListAllRuleServiceEntries ¶
func (q *Queries) ListAllRuleServiceEntries(ctx context.Context) ([]RuleServiceEntry, error)
func (*Queries) ListAllRuleServiceRefs ¶
func (q *Queries) ListAllRuleServiceRefs(ctx context.Context) ([]RuleServiceRef, error)
func (*Queries) ListAllRulesetScopeMatches ¶
func (q *Queries) ListAllRulesetScopeMatches(ctx context.Context) ([]RulesetScopeMatch, error)
func (*Queries) ListAllServiceEntries ¶
func (q *Queries) ListAllServiceEntries(ctx context.Context) ([]ServiceEntry, error)
func (*Queries) ListAllWorkloadAddresses ¶
func (q *Queries) ListAllWorkloadAddresses(ctx context.Context) ([]WorkloadAddress, error)
func (*Queries) ListAllWorkloadLabels ¶
func (q *Queries) ListAllWorkloadLabels(ctx context.Context) ([]WorkloadLabel, error)
func (*Queries) ListFlowGaps ¶
The gaps of a workload set that intersect [since, until): a gap [gap_from, gap_to) intersects it when it starts before the range ends and ends after the range starts; an instantaneous gap intersects when its instant lies in the range. Newest first, bounded; an empty workload id array means every workload.
func (*Queries) ListFlowTotals ¶
func (*Queries) ListFlowWindowPage ¶
func (q *Queries) ListFlowWindowPage(ctx context.Context, arg ListFlowWindowPageParams) ([]FlowWindow, error)
One page of a workload's windows, newest first, keyed by (window_start, id) so a page never shifts when new windows land. The first page passes a cursor beyond any row. An empty peer key means every peer; a zero protocol means every service.
func (*Queries) ListFlowWindows ¶
func (q *Queries) ListFlowWindows(ctx context.Context, arg ListFlowWindowsParams) ([]FlowWindow, error)
func (*Queries) ListModeChangeWorkloads ¶
func (*Queries) ListOperatorTokens ¶
func (q *Queries) ListOperatorTokens(ctx context.Context) ([]OperatorToken, error)
func (*Queries) ListProvisioningTokenLabels ¶
func (*Queries) ListProvisioningTokens ¶
func (q *Queries) ListProvisioningTokens(ctx context.Context) ([]ProvisioningToken, error)
func (*Queries) ListRulesets ¶
func (*Queries) ListServiceEntries ¶
func (*Queries) ListServices ¶
func (*Queries) ListWorkloadAddresses ¶
func (*Queries) ListWorkloadAddressesFor ¶
func (*Queries) ListWorkloadLabels ¶
func (*Queries) ListWorkloadLabelsFor ¶
func (q *Queries) ListWorkloadLabelsFor(ctx context.Context, workloadIds []uuid.UUID) ([]WorkloadLabel, error)
The children of the workloads on one page, fetched once per page.
func (*Queries) ListWorkloadListeningServices ¶
func (*Queries) ListWorkloadListeningServicesFor ¶
func (*Queries) ListWorkloadPage ¶
func (q *Queries) ListWorkloadPage(ctx context.Context, arg ListWorkloadPageParams) ([]ListWorkloadPageRow, error)
--- operator read model (ADR-0007 as amended) ------------------------------- One page of the fleet in the order the fleet screen shows it: the workloads needing attention first (degraded or enforcement removed, then offline, then pending, then synced), most recently seen first within a rank, then by id. A workload whose owned table is recorded absent (migration 00012) ranks with the degraded ones whatever its stored sync state, which stays the agent's honest record (issue #96). The cursor is the (rank, last seen, id) of the last row served; the first page passes a rank below every row. A workload never seen sorts as if seen at the epoch. An empty id array means every workload; a zero mode or sync state means any. The latest rendered version rides along from workload_policies so sync drift is one read.
A retired workload is outside the attention ordering (ADR-0023): the lifecycle argument selects active workloads (1) or retired ones (2), never both, and a retired one takes a rank of its own below every other with its retirement instant as the sort key, so the retired list runs most recently retired first through the same cursor.
func (*Queries) ListWorkloadPolicies ¶
func (q *Queries) ListWorkloadPolicies(ctx context.Context) ([]WorkloadPolicy, error)
func (*Queries) ListWorkloads ¶
--- inventory and status (ADR-0018) ------------------------------------------
func (*Queries) LockWorkload ¶ added in v0.5.0
--- retirement (ADR-0023) ---------------------------------------------------- The row a retirement or a label write locks before it reads, so the two serialize with each other and with flow ingest's receipt: the instant it was retired (NULL while active), and what the silence derivation reads, the last report's receipt and the latest heartbeat's pair.
func (*Queries) NotifyDirective ¶
func (q *Queries) NotifyDirective(ctx context.Context, arg NotifyDirectiveParams) error
A directive for the stream of one workload rides the same channel as render announcements, keyed by the workload; the replica holding that stream, if any, sends it (ADR-0018 as amended). It is sent outside any transaction, so it is delivered at once.
func (*Queries) NotifyPolicyChanged ¶
func (q *Queries) NotifyPolicyChanged(ctx context.Context, arg NotifyPolicyChangedParams) error
func (*Queries) Ping ¶
Queries are hand-written SQL compiled by sqlc into internal/store/db (ADR-0006). One file per concern; every production query lives here.
Ping is a connectivity probe that touches no tables. It exists so the data layer is exercised end to end before the first migration lands.
func (*Queries) RecordOperatorTokenUse ¶
func (q *Queries) RecordOperatorTokenUse(ctx context.Context, arg RecordOperatorTokenUseParams) error
func (*Queries) RecordProvisioningTokenUse ¶
func (q *Queries) RecordProvisioningTokenUse(ctx context.Context, arg RecordProvisioningTokenUseParams) error
func (*Queries) RecordWorkloadAgent ¶
func (q *Queries) RecordWorkloadAgent(ctx context.Context, arg RecordWorkloadAgentParams) (int64, error)
The Hello also stamps the credential the stream opened on (migration 00018); a caller that knows of none passes both NULL and leaves the stamp as it was, so the pair is never half-written or made up.
func (*Queries) RecordWorkloadApplied ¶
func (q *Queries) RecordWorkloadApplied(ctx context.Context, arg RecordWorkloadAppliedParams) (int64, error)
An APPLIED acknowledgement: the version, the resulting state, and the instant. Nothing else writes last_acked_at (migration 00007). An apply that succeeded installed the owned table, so a table recorded absent is present again (migration 00012).
func (*Queries) RecordWorkloadApplyFailed ¶
func (q *Queries) RecordWorkloadApplyFailed(ctx context.Context, arg RecordWorkloadApplyFailedParams) (int64, error)
A FAILED acknowledgement: the degraded state, the agent's detail, and the instant. The applied version is untouched; the agent is still on it. Nothing else writes last_apply_failed_at (migration 00007).
func (*Queries) RecordWorkloadClockReading ¶ added in v0.2.0
func (q *Queries) RecordWorkloadClockReading(ctx context.Context, arg RecordWorkloadClockReadingParams) error
One flow report's reading of the agent's clock (migration 00010). A skewed reading records its offset and instant and marks the skew current; a reading within tolerance only clears the mark, and writes nothing when there is no mark to clear, so a healthy agent's reports cost no write.
func (*Queries) RecordWorkloadFlowReport ¶ added in v0.2.0
func (q *Queries) RecordWorkloadFlowReport(ctx context.Context, arg RecordWorkloadFlowReportParams) ([]RecordWorkloadFlowReportRow, error)
The receipt of one flow report (migration 00013). Never moved backwards, so reports handled out of order across replicas leave the latest. The row it replaces comes back so ingest can derive the agent-silence gap (migration 00015): the locking subquery serializes concurrent reports of one workload, so each silence is seen by exactly one of them. The latest heartbeat's receipt and process start ride along, read under the same lock, so the derivation can tell a quiet agent from an absent one (migration 00016). No row means the receipt did not advance (a stale report, or no such workload). A retired workload's receipt never moves: its retirement closed the silence the receipt would bound, under the same row lock, so a report racing it derives nothing twice (ADR-0023).
func (*Queries) RecordWorkloadHeartbeat ¶
func (q *Queries) RecordWorkloadHeartbeat(ctx context.Context, arg RecordWorkloadHeartbeatParams) (int64, error)
A heartbeat's counters, renewal status, and owned-table state (migration 00012). An unknown state leaves the stored one; the absent instant is the first heartbeat's that said absent, kept while the state stays absent. The heartbeat's receipt and the start of the process it came from are written together, so the pair is always one heartbeat's (migration 00016).
func (*Queries) RecordWorkloadHeartbeatSeen ¶
func (*Queries) RecordWorkloadInventory ¶
func (q *Queries) RecordWorkloadInventory(ctx context.Context, arg RecordWorkloadInventoryParams) (int64, error)
The writes a sync stream makes from what its agent sends (inventory, Hello, heartbeats, acknowledgements) are conditioned on the workload not being retired: no row means it is unknown or retired, and the stream of a retired workload ends at the next one (ADR-0023).
func (*Queries) RecordWorkloadRenewal ¶
func (q *Queries) RecordWorkloadRenewal(ctx context.Context, arg RecordWorkloadRenewalParams) (int64, error)
A late renewal (one made with an already-expired credential, within the grace) also replaces the workload's late-renewal record; an on-time one leaves it (ADR-0016 as amended). A retired workload renews nothing (ADR-0023): the write is conditioned on it, so a retirement committed after the renewal was admitted still refuses it here.
func (*Queries) RecordWorkloadSnapshotSent ¶
func (q *Queries) RecordWorkloadSnapshotSent(ctx context.Context, arg RecordWorkloadSnapshotSentParams) (int64, error)
Stamped by the sync path whenever it sends the workload a snapshot, whatever caused it; nothing else writes it (ADR-0018 as amended).
func (*Queries) RetireWorkload ¶ added in v0.5.0
Retirement stamps the instant once; nothing clears it.
func (*Queries) RevokeOperatorToken ¶
func (*Queries) RevokeProvisioningToken ¶
func (*Queries) RollupFlowWindows ¶
func (q *Queries) RollupFlowWindows(ctx context.Context, arg RollupFlowWindowsParams) ([]RollupFlowWindowsRow, error)
The rollup the operator console issues for a label scope: the scope is resolved to workload ids by the caller, and the rows are grouped by resolved peer and service (destination port and protocol). A decision of 0 means every decision.
func (*Queries) RollupFlowsByDstService ¶
func (q *Queries) RollupFlowsByDstService(ctx context.Context, arg RollupFlowsByDstServiceParams) ([]RollupFlowsByDstServiceRow, error)
Grouped by the reporting workload and the service reached on it: the cells of the matrix.
func (*Queries) RollupFlowsByPeerService ¶
func (q *Queries) RollupFlowsByPeerService(ctx context.Context, arg RollupFlowsByPeerServiceParams) ([]RollupFlowsByPeerServiceRow, error)
Grouped by the resolved peer and the service it reached, across every workload in scope, with the number of distinct workloads that saw it: the rows of a simulation review (ADR-0019 decision 4(b)). The label snapshot of a peer is the one stored with its most recently seen record.
func (*Queries) RollupFlowsByRule ¶
func (q *Queries) RollupFlowsByRule(ctx context.Context, arg RollupFlowsByRuleParams) ([]RollupFlowsByRuleRow, error)
--- operator read model -----------------------------------------------------
The rollups the operator surface and the command line issue (ADR-0007 as amended, ADR-0019 decision 4). Each grouping the surface offers is one named statement over the same windows; the caller picks the statement and never assembles one. Every rollup shares one filter convention: an empty workload id array means every workload; a non-empty one selects the records those workloads reported, and with either_endpoint also the records whose source resolved at ingest to one of them (peer kind 1, a workload, keyed by its id), each record once; a zero decision or direction means any, and a zero protocol means every service (a service is one destination port and protocol). Ordering is by connection count unless order_by is 'recent', in which case the most recently seen group comes first. The window bounds actually covered, the number of groups, and the totals across every group ride on each row as window aggregates, so a truncated result still says how it relates to the whole. The decision-and-time and workload-and-time indexes serve all five. Grouped by the resolved rule that admitted the traffic; records with no matched rule form the group with the empty rule id. Each group counts the distinct workloads that reported it, since a rule's key names none.
func (*Queries) RollupFlowsByRulePeer ¶
func (q *Queries) RollupFlowsByRulePeer(ctx context.Context, arg RollupFlowsByRulePeerParams) ([]RollupFlowsByRulePeerRow, error)
Grouped by rule and the resolved peer that hit it. The label snapshot of a peer is the one stored with its most recently seen record.
func (*Queries) RollupFlowsBySrcDst ¶
func (q *Queries) RollupFlowsBySrcDst(ctx context.Context, arg RollupFlowsBySrcDstParams) ([]RollupFlowsBySrcDstRow, error)
Grouped by the resolved source peer and the reporting workload: the edges of the dependency map. Inbound only in this version, so the source is the peer and the destination is the workload.
func (*Queries) SetOperator ¶
func (*Queries) SetWorkloadMode ¶
func (*Queries) SetWorkloadModes ¶
func (*Queries) SetWorkloadSyncState ¶
func (*Queries) TryAcquireRetentionLock ¶
Retention runs singly across replicas: whichever replica acquires the lock prunes, the others skip this round (ADR-0017).
func (*Queries) UpdateAddressGroup ¶
func (q *Queries) UpdateAddressGroup(ctx context.Context, arg UpdateAddressGroupParams) (int64, error)
Conditional writes: expected is the version token the caller last read, compared byte-exact against the stored version's decimal form, or NULL for an unconditional write. Every write advances the version by one.
func (*Queries) UpdateRuleset ¶
A conditional write: expected is the version token the caller last read, compared byte-exact against the stored version's decimal form, or NULL for an unconditional write (the command line's default). Every write advances the version by one and returns it. No row with a NULL expected means the ruleset does not exist; no row with one set means either that or a version the caller did not see.
func (*Queries) UpdateService ¶
Conditional writes: expected is the version token the caller last read, compared byte-exact against the stored version's decimal form, or NULL for an unconditional write. Every write advances the version by one.
func (*Queries) UpsertFlowTotal ¶
func (q *Queries) UpsertFlowTotal(ctx context.Context, arg []UpsertFlowTotalParams) *UpsertFlowTotalBatchResults
func (*Queries) UpsertWorkloadPolicy ¶
func (q *Queries) UpsertWorkloadPolicy(ctx context.Context, arg UpsertWorkloadPolicyParams) error
type RecordWorkloadClockReadingParams ¶ added in v0.2.0
type RecordWorkloadFlowReportParams ¶ added in v0.2.0
type RecordWorkloadFlowReportRow ¶ added in v0.4.0
type RetireWorkloadParams ¶ added in v0.5.0
type RollupFlowWindowsParams ¶
type RollupFlowWindowsRow ¶
type RollupFlowsByDstServiceRow ¶
type RollupFlowsByDstServiceRow struct {
WorkloadID uuid.UUID
DstPort int32
Protocol int32
FlowCount int64
ConnectionCount int64
ByteCount int64
FirstSeen time.Time
LastSeen time.Time
EffectiveFrom time.Time
EffectiveTo time.Time
GroupCount int64
TotalFlowCount int64
TotalConnectionCount int64
TotalByteCount int64
}
type RollupFlowsByPeerServiceRow ¶
type RollupFlowsByPeerServiceRow struct {
PeerKind int32
PeerKey string
PeerLabels []byte
DstPort int32
Protocol int32
WorkloadCount int64
FlowCount int64
ConnectionCount int64
ByteCount int64
FirstSeen time.Time
LastSeen time.Time
EffectiveFrom time.Time
EffectiveTo time.Time
GroupCount int64
TotalFlowCount int64
TotalConnectionCount int64
TotalByteCount int64
}
type RollupFlowsByRuleParams ¶
type RollupFlowsByRulePeerRow ¶
type RollupFlowsByRulePeerRow struct {
MatchedRuleID string
PeerKind int32
PeerKey string
PeerLabels []byte
FlowCount int64
ConnectionCount int64
ByteCount int64
FirstSeen time.Time
LastSeen time.Time
EffectiveFrom time.Time
EffectiveTo time.Time
GroupCount int64
TotalFlowCount int64
TotalConnectionCount int64
TotalByteCount int64
}
type RollupFlowsByRuleRow ¶
type RollupFlowsByRuleRow struct {
MatchedRuleID string
WorkloadCount int64
FlowCount int64
ConnectionCount int64
ByteCount int64
FirstSeen time.Time
LastSeen time.Time
EffectiveFrom time.Time
EffectiveTo time.Time
GroupCount int64
TotalFlowCount int64
TotalConnectionCount int64
TotalByteCount int64
}
type RollupFlowsBySrcDstRow ¶
type RollupFlowsBySrcDstRow struct {
PeerKind int32
PeerKey string
PeerLabels []byte
WorkloadID uuid.UUID
FlowCount int64
ConnectionCount int64
ByteCount int64
FirstSeen time.Time
LastSeen time.Time
EffectiveFrom time.Time
EffectiveTo time.Time
GroupCount int64
TotalFlowCount int64
TotalConnectionCount int64
TotalByteCount int64
}
type RulePeerMatch ¶
type RuleServiceEntry ¶
type RulesetScopeMatch ¶
type ServiceEntry ¶
type SetOperatorParams ¶
type SetWorkloadModeParams ¶
type SetWorkloadModesParams ¶
type UpdateRulesetParams ¶
type UpdateServiceParams ¶
type UpsertFlowTotalBatchResults ¶
type UpsertFlowTotalBatchResults struct {
// contains filtered or unexported fields
}
func (*UpsertFlowTotalBatchResults) Close ¶
func (b *UpsertFlowTotalBatchResults) Close() error
func (*UpsertFlowTotalBatchResults) Exec ¶
func (b *UpsertFlowTotalBatchResults) Exec(f func(int, error))
type UpsertFlowTotalParams ¶
type Workload ¶
type Workload struct {
ID uuid.UUID
RegionID string
ProvisioningTokenID uuid.UUID
Hostname string
EnrolledAt time.Time
CredentialSerial string
CredentialExpiresAt time.Time
LastRenewedAt *time.Time
Mode int32
Facts []byte
AgentVersion string
AgentCapabilities []string
LastSeenAt *time.Time
SyncState int32
AppliedPolicyVersion int64
SyncError string
DroppedFlowRecords int64
CredentialRenewalError string
LastSnapshotSentAt *time.Time
LastAckedAt *time.Time
LastApplyFailedAt *time.Time
SourceOverruns int64
ClockSkewOffsetMs pgtype.Int8
ClockSkewObservedAt *time.Time
ClockSkewCurrent bool
OwnedTableState int16
OwnedTableAbsentSince *time.Time
LastFlowReportAt *time.Time
LateRenewalAt *time.Time
LateRenewalExpiredAt *time.Time
LastHeartbeatAt *time.Time
AgentStartedAt *time.Time
RetiredAt *time.Time
PresentedCredentialSerial *string
PresentedCredentialExpiresAt *time.Time
}