Documentation
¶
Index ¶
- type ApiToken
- type AuditLog
- type CountEventsParams
- type CurrentResource
- type DBTX
- type Event
- type IngestCredential
- type ListCandidatesParams
- type ListCandidatesRow
- type ListHistoryParams
- type ListLateEventsParams
- type ListLateEventsRow
- type ListProjectsRow
- type ListRelationsOverlappingParams
- type ListRelationsOverlappingRow
- type Project
- type ProjectRelation
- type Queries
- func (q *Queries) CountEvents(ctx context.Context, arg CountEventsParams) (int64, error)
- func (q *Queries) ListCandidates(ctx context.Context, arg ListCandidatesParams) ([]ListCandidatesRow, error)
- func (q *Queries) ListHistory(ctx context.Context, arg ListHistoryParams) ([]Event, error)
- func (q *Queries) ListLateEvents(ctx context.Context, arg ListLateEventsParams) ([]ListLateEventsRow, error)
- func (q *Queries) ListProjects(ctx context.Context) ([]ListProjectsRow, error)
- func (q *Queries) ListRelationsOverlapping(ctx context.Context, arg ListRelationsOverlappingParams) ([]ListRelationsOverlappingRow, error)
- func (q *Queries) SnapshotTime(ctx context.Context) (pgtype.Timestamptz, error)
- func (q *Queries) WithTx(tx pgx.Tx) *Queries
- type RejectedEvent
- type ResourceType
- type SizeName
- type SyncRun
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CountEventsParams ¶
type CountEventsParams struct {
Cloud string
ResourceType string
ResourceID string
EventType string
FromTs pgtype.Timestamptz
ToTs pgtype.Timestamptz
}
type CurrentResource ¶
type CurrentResource struct {
Cloud string
Platform string
ResourceType string
ResourceID string
ProjectID string
State string
Size []byte
CreatedAt pgtype.Timestamptz
DeletedAt pgtype.Timestamptz
LastEventType string
LastEventAt pgtype.Timestamptz
LastPayload []byte
FirstEventAt pgtype.Timestamptz
}
type IngestCredential ¶
type ListCandidatesParams ¶
type ListCandidatesParams struct {
Clouds []string
PeriodFrom pgtype.Timestamptz
PeriodTo pgtype.Timestamptz
}
type ListCandidatesRow ¶
type ListHistoryParams ¶
type ListHistoryParams struct {
Cloud string
ResourceType string
ResourceID string
PeriodTo pgtype.Timestamptz
}
type ListLateEventsParams ¶
type ListLateEventsParams struct {
MaxResources int64
PeriodFrom pgtype.Timestamptz
PeriodTo pgtype.Timestamptz
Since pgtype.Timestamptz
}
type ListLateEventsRow ¶
type ListProjectsRow ¶
type ListRelationsOverlappingParams ¶
type ListRelationsOverlappingParams struct {
RelationTypes []string
PeriodTo pgtype.Timestamptz
PeriodFrom pgtype.Timestamptz
}
type ProjectRelation ¶
type ProjectRelation struct {
ID uuid.UUID
SourceID uuid.UUID
TargetID uuid.UUID
RelationType string
Metadata []byte
ValidFrom pgtype.Timestamptz
ValidTo pgtype.Timestamptz
CreatedAt pgtype.Timestamptz
}
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) CountEvents ¶
The events of one type a counter measures inside one usage interval. The interval is half-open, [from_ts, to_ts), the same bound the interval itself has, and the key carries the cloud and the resource type beside the id because an id is unique only within both. idx_events_resource serves the predicate on uncompressed chunks; a chunk past the 90-day compression policy is segmented by (cloud, resource_type) alone, so the resource id and the event type are filtered after decompression, which is what a correction of an older period pays.
func (*Queries) ListCandidates ¶
func (q *Queries) ListCandidates(ctx context.Context, arg ListCandidatesParams) ([]ListCandidatesRow, error)
The resources a period can bill. The projection is the index: its rows are never deleted, so a resource that lived during the period is still there to be found, whatever happened to it since. A NULL cloud list means every cloud.
func (*Queries) ListHistory ¶
The full history of one candidate up to the period end. The fold starts at the first event there is, because the state the resource holds at the period start is whatever the events before it left behind.
func (*Queries) ListLateEvents ¶
func (q *Queries) ListLateEvents(ctx context.Context, arg ListLateEventsParams) ([]ListLateEventsRow, error)
The late events of one billing period, the detection of WP 3.9 (roadmap/03-phase-3-metering-rating.md, under "Late-event detection"): the events dated inside the period that were received strictly after the instant the caller passes, the runs.stats.snapshot_at of the finalized run, grouped per resource. The range over timestamp is answered by chunk exclusion, and the lower bound on received_at by idx_events_received (reporting migration 0009) on the uncompressed chunks; a chunk past the 90-day compression policy is segmented by (cloud, resource_type) and ordered by nothing, so its batches carry no bounds on received_at and are filtered after decompression, which is what detecting the late events of an older period pays.
The groups are bounded by max_resources. A period finalized before its ingest had settled has one group per resource of the fleet, and what a caller does with the groups is print one line each. The groups the limit cuts off are counted all the same: resources is how many arrived late whatever the limit let through, and every row carries it, so a caller that read one row knows how many it did not.
The strict comparison leaves one window open, and the issue holds it as a Non-Goal: an ingest transaction that began before the snapshot and committed after it carries a received_at below snapshot_at, so its events are not listed here although a correction of the period re-meters them. Ingest transactions are milliseconds long, and the window is recorded here rather than papered over with a margin.
func (*Queries) ListProjects ¶
func (q *Queries) ListProjects(ctx context.Context) ([]ListProjectsRow, error)
The project registry, read whole: attribution walks the graph over these UUIDs, and the resources it walks from carry the external id rather than the registry's.
func (*Queries) ListRelationsOverlapping ¶
func (q *Queries) ListRelationsOverlapping(ctx context.Context, arg ListRelationsOverlappingParams) ([]ListRelationsOverlappingRow, error)
The relations that apply to a period, which are the ones whose validity overlaps it (D4). A relation closed inside the period still carries the cost the period produced before it closed; v1 does not prorate a relation within a period.
func (*Queries) SnapshotTime ¶
The first statement of the REPEATABLE READ transaction a run opens. Reading now() takes the snapshot every later query in that transaction sees, and the value it returns is that snapshot's time, which the run records in runs.stats.snapshot_at.
type RejectedEvent ¶
type ResourceType ¶
type ResourceType struct {
Platform string
ResourceType string
SizeSchema []byte
UpdatedAt pgtype.Timestamptz
}