Files
wehub-resource-sync 75f3dd141c
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CI and Release / lint-frontend (push) Has been cancelled
CI and Release / dockerfile-scan (push) Has been cancelled
CI and Release / test-frontend (push) Has been cancelled
CI and Release / lint-verification-agent (push) Has been cancelled
CI and Release / test-verification-agent (push) Has been cancelled
CI and Release / e2e-verification-agent (push) Has been cancelled
CI and Release / test-backend (push) Has been cancelled
CI and Release / build-dev-image (push) Has been cancelled
CI and Release / push-dev-image (push) Has been cancelled
CI and Release / build-image (push) Has been cancelled
CI and Release / build-verification-image (push) Has been cancelled
CI and Release / determine-version (push) Has been cancelled
CI and Release / push-image (push) Has been cancelled
CI and Release / push-verification-image (12) (push) Has been cancelled
CI and Release / lint-backend (push) Has been cancelled
CI and Release / push-verification-image (17) (push) Has been cancelled
CI and Release / push-verification-image (18) (push) Has been cancelled
CI and Release / release (push) Has been cancelled
CI and Release / publish-helm-chart (push) Has been cancelled
CI and Release / push-verification-image (13) (push) Has been cancelled
CI and Release / push-verification-image (14) (push) Has been cancelled
CI and Release / push-verification-image (15) (push) Has been cancelled
CI and Release / push-verification-image (16) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:11:07 +08:00

89 lines
2.7 KiB
Go

package api
import (
"fmt"
"net/http"
"time"
"github.com/google/uuid"
)
type HeartbeatRequest struct {
MaxCPU int `json:"maxCpu"`
MaxRAMGb int `json:"maxRamGb"`
MaxDiskGb int `json:"maxDiskGb"`
MaxConcurrentJobs int `json:"maxConcurrentJobs"`
CurrentVerificationIDs []uuid.UUID `json:"currentVerificationIds"`
}
type HeartbeatResponse struct {
LastSeenAt time.Time `json:"lastSeenAt"`
AbortVerificationIDs []uuid.UUID `json:"abortVerificationIds"`
}
type versionResponse struct {
Version string `json:"version"`
}
type AgentCapacity struct {
MaxCPU int `json:"maxCpu"`
MaxRAMMb int `json:"maxRamMb"`
MaxDiskGb int `json:"maxDiskGb"`
MaxConcurrentJobs int `json:"maxConcurrentJobs"`
}
type ClaimRequest struct {
Capacity AgentCapacity `json:"capacity"`
}
type AssignedPostgresql struct {
Version string `json:"version"`
}
type AssignedDatabase struct {
Type string `json:"type"`
PostgresqlLogical *AssignedPostgresql `json:"postgresqlLogical"`
}
type JobAssignment struct {
VerificationID uuid.UUID `json:"verificationId"`
BackupID uuid.UUID `json:"backupId"`
BackupSizeMb float64 `json:"backupSizeMb"`
MaxContainerDiskMb float64 `json:"maxContainerDiskMb"`
Database AssignedDatabase `json:"database"`
TimescaledbVersion string `json:"timescaledbVersion"`
}
type ReportTableStat struct {
SchemaName string `json:"schemaName"`
Name string `json:"name"`
RowCount int64 `json:"rowCount"`
}
type ReportRequest struct {
Status VerificationStatus `json:"status"`
PgRestoreExitCode *int `json:"pgRestoreExitCode"`
FailureKind *FailureType `json:"failureKind"`
RestoreDurationMs *int64 `json:"restoreDurationMs"`
VerifyDurationMs *int64 `json:"verifyDurationMs"`
DBSizeBytesAfterRestore *int64 `json:"dbSizeBytesAfterRestore"`
TableCount *int `json:"tableCount"`
SchemaCount *int `json:"schemaCount"`
TableStats []ReportTableStat `json:"tableStats"`
FailMessage *string `json:"failMessage"`
}
type ResponseError struct {
Op string
StatusCode int
Body string
}
func (e *ResponseError) Error() string {
return fmt.Sprintf("%s: server returned status %d: %s", e.Op, e.StatusCode, e.Body)
}
func (e *ResponseError) Retryable() bool { return e.StatusCode >= 500 }
func (e *ResponseError) IsGone() bool { return e.StatusCode == http.StatusGone }