feat(store): add monitors, regions, agents and check result hypertable
check_results has no row-level security because TimescaleDB refuses compression and continuous aggregates on such tables. Every results query takes org_id as a parameter, which a test enforces. Refs #10, #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
55559c8b0a
commit
00658d49a2
12 files changed
+1093
No files matched your search
@@ -10,6 +10,19 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Agent struct {
|
||||
ID uuid.UUID
|
||||
OrgID *uuid.UUID
|
||||
Kind string
|
||||
Name string
|
||||
Region *string
|
||||
TokenHash []byte
|
||||
Prefix string
|
||||
LastSeenAt *time.Time
|
||||
Release *string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type ApiToken struct {
|
||||
ID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
@@ -23,6 +36,40 @@ type ApiToken struct {
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type CheckResult struct {
|
||||
Time time.Time
|
||||
OrgID uuid.UUID
|
||||
MonitorID uuid.UUID
|
||||
Region string
|
||||
CheckerID uuid.UUID
|
||||
Ok bool
|
||||
LatencyMs *int32
|
||||
StatusCode *int32
|
||||
Error *string
|
||||
}
|
||||
|
||||
type CheckResults1d struct {
|
||||
Bucket interface{}
|
||||
OrgID uuid.UUID
|
||||
MonitorID uuid.UUID
|
||||
Region string
|
||||
Total int64
|
||||
OkCount int64
|
||||
AvgLatencyMs float32
|
||||
MaxLatencyMs interface{}
|
||||
}
|
||||
|
||||
type CheckResults1h struct {
|
||||
Bucket interface{}
|
||||
OrgID uuid.UUID
|
||||
MonitorID uuid.UUID
|
||||
Region string
|
||||
Total int64
|
||||
OkCount int64
|
||||
AvgLatencyMs float32
|
||||
MaxLatencyMs interface{}
|
||||
}
|
||||
|
||||
type Invitation struct {
|
||||
ID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
@@ -42,6 +89,26 @@ type Membership struct {
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Monitor struct {
|
||||
ID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
Name string
|
||||
Type string
|
||||
Target string
|
||||
IntervalSeconds int32
|
||||
TimeoutMs int32
|
||||
Config []byte
|
||||
Enabled bool
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type MonitorRegion struct {
|
||||
MonitorID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
Region string
|
||||
}
|
||||
|
||||
type Org struct {
|
||||
ID uuid.UUID
|
||||
Slug string
|
||||
@@ -60,6 +127,12 @@ type RecoveryCode struct {
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Region struct {
|
||||
Key string
|
||||
Name string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Role struct {
|
||||
ID uuid.UUID
|
||||
OrgID *uuid.UUID
|
||||
|
||||
Reference in new issue
Block a user