Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Instance errors ErrInstanceNotFound = errors.New("instance not found") ErrInstanceRevoked = errors.New("instance is revoked") ErrInvalidInstanceID = errors.New("invalid instance ID") ErrInvalidPublicKey = errors.New("invalid public key") ErrInvalidInstance = errors.New("invalid instance") ErrInvalidStatusTransition = errors.New("invalid status transition") // Snapshot errors ErrInvalidSnapshot = errors.New("invalid snapshot") ErrInvalidMetrics = errors.New("invalid metrics") // Application errors ErrApplicationNotFound = errors.New("application not found") ErrInvalidApplicationID = errors.New("invalid application ID") ErrInvalidAppSlug = errors.New("invalid application slug") ErrInvalidGitHubURL = errors.New("invalid GitHub URL") ErrInvalidApplication = errors.New("invalid application") // Authentication errors ErrInvalidSignature = errors.New("invalid signature") ErrMissingSignature = errors.New("missing signature") )
Functions ¶
This section is empty.
Types ¶
type AppSlug ¶ added in v1.2.0
type AppSlug string
AppSlug is a validated, URL-safe application slug.
func NewAppSlug ¶ added in v1.2.0
NewAppSlug creates and validates an AppSlug.
type Application ¶ added in v1.2.0
type Application struct {
ID ApplicationID
Slug AppSlug
Name string
GitHubURL GitHubURL
Stars int
StarsUpdatedAt *time.Time
LogoURL string // Optional custom logo
CreatedAt time.Time
UpdatedAt time.Time
}
Application represents an application that can have multiple instances.
func NewApplication ¶ added in v1.2.0
func NewApplication(slug, name string) (*Application, error)
NewApplication creates a new Application with validation.
func (*Application) NeedsStarsRefresh ¶ added in v1.2.0
func (a *Application) NeedsStarsRefresh() bool
NeedsStarsRefresh returns true if stars data is stale (older than 1 hour).
func (*Application) SetGitHubURL ¶ added in v1.2.0
func (a *Application) SetGitHubURL(urlStr string) error
SetGitHubURL updates the GitHub repository URL.
func (*Application) SetLogoURL ¶ added in v1.2.0
func (a *Application) SetLogoURL(logoURL string)
SetLogoURL updates the custom logo URL.
func (*Application) UpdateStars ¶ added in v1.2.0
func (a *Application) UpdateStars(stars int)
UpdateStars updates the GitHub stars count and timestamp.
type ApplicationID ¶ added in v1.2.0
type ApplicationID string
ApplicationID is a validated application identifier (UUID format).
func NewApplicationID ¶ added in v1.2.0
func NewApplicationID(id string) (ApplicationID, error)
NewApplicationID creates and validates an ApplicationID.
func (ApplicationID) String ¶ added in v1.2.0
func (id ApplicationID) String() string
String returns the string representation.
type GitHubURL ¶ added in v1.2.0
type GitHubURL string
GitHubURL is a validated GitHub repository URL.
func NewGitHubURL ¶ added in v1.2.0
NewGitHubURL creates and validates a GitHubURL.
func (GitHubURL) OwnerAndRepo ¶ added in v1.2.0
OwnerAndRepo extracts the owner and repository name from the URL.
type Instance ¶
type Instance struct {
ID InstanceID
PublicKey PublicKey
ApplicationID ApplicationID // Foreign key to applications table
AppName string // Denormalized for compatibility
AppVersion string
DeploymentMode string
Environment string
OSArch string
Status InstanceStatus
LastSeenAt time.Time
CreatedAt time.Time
}
Instance represents a registered telemetry client instance.
func NewInstance ¶
func NewInstance( instanceID string, publicKey string, appName string, appVersion string, deploymentMode string, environment string, osArch string, ) (*Instance, error)
NewInstance creates a new Instance with validation.
func (*Instance) UpdateHeartbeat ¶
func (i *Instance) UpdateHeartbeat()
UpdateHeartbeat updates the last seen timestamp.
type InstanceID ¶
type InstanceID string
InstanceID is a validated instance identifier (UUID format).
func NewInstanceID ¶
func NewInstanceID(id string) (InstanceID, error)
NewInstanceID creates and validates an InstanceID.
func (InstanceID) String ¶
func (id InstanceID) String() string
String returns the string representation.
type InstanceStatus ¶
type InstanceStatus string
InstanceStatus represents the lifecycle state of an instance.
const ( StatusPending InstanceStatus = "pending" StatusActive InstanceStatus = "active" StatusRevoked InstanceStatus = "revoked" )
func (InstanceStatus) CanTransitionTo ¶
func (s InstanceStatus) CanTransitionTo(target InstanceStatus) bool
CanTransitionTo checks if a status transition is allowed.
func (InstanceStatus) Valid ¶
func (s InstanceStatus) Valid() bool
Valid returns true if the status is a known value.
type Metrics ¶
Metrics represents schema-agnostic telemetry data. Stored as JSON, can contain any numeric or string values.
func NewMetrics ¶
func NewMetrics(raw json.RawMessage) (Metrics, error)
NewMetrics creates Metrics from raw JSON bytes.
func (Metrics) GetFloat64 ¶
GetFloat64 retrieves a numeric metric value. Returns 0 and false if the key doesn't exist or isn't numeric.
func (Metrics) Raw ¶
func (m Metrics) Raw() (json.RawMessage, error)
Raw returns the JSON representation of the metrics.
func (Metrics) SumNumeric ¶
SumNumeric returns the sum of all numeric values in the metrics.
type PublicKey ¶
type PublicKey string
PublicKey is a hex-encoded Ed25519 public key.
func NewPublicKey ¶
NewPublicKey creates and validates a PublicKey.
type Snapshot ¶
type Snapshot struct {
ID int64
InstanceID InstanceID
SnapshotAt time.Time
Metrics Metrics
}
Snapshot represents a point-in-time telemetry capture from an instance.
func NewSnapshot ¶
func NewSnapshot(instanceID string, timestamp time.Time, metrics json.RawMessage) (*Snapshot, error)
NewSnapshot creates a new Snapshot with validation.