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") // Authentication errors ErrInvalidSignature = errors.New("invalid signature") ErrMissingSignature = errors.New("missing signature") )
Functions ¶
This section is empty.
Types ¶
type Instance ¶
type Instance struct {
ID InstanceID
PublicKey PublicKey
AppName string
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.