app

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2025 License: AGPL-3.0, AGPL-3.0-or-later Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DashboardService

type DashboardService struct {
	// contains filtered or unexported fields
}

DashboardService handles dashboard-related use cases. This is a read-only service (CQRS-lite pattern).

func NewDashboardService

func NewDashboardService(reader ports.DashboardReader) *DashboardService

NewDashboardService creates a new DashboardService.

func (*DashboardService) GetMetricsTimeSeries

func (s *DashboardService) GetMetricsTimeSeries(ctx context.Context, appName string, period Period) (ports.MetricsTimeSeries, error)

GetMetricsTimeSeries returns time-series metrics for an app.

func (*DashboardService) GetStats

GetStats returns aggregated dashboard statistics.

func (*DashboardService) ListInstances

func (s *DashboardService) ListInstances(ctx context.Context, limit int) ([]ports.InstanceSummary, error)

ListInstances returns instances with their latest metrics.

type InstanceService

type InstanceService struct {
	// contains filtered or unexported fields
}

InstanceService handles instance-related use cases.

func NewInstanceService

func NewInstanceService(repo ports.InstanceRepository) *InstanceService

NewInstanceService creates a new InstanceService.

func (*InstanceService) Activate

func (s *InstanceService) Activate(ctx context.Context, instanceID string) error

Activate transitions an instance from pending to active status. This requires a valid signature (verified by middleware before calling this).

func (*InstanceService) GetPublicKey

func (s *InstanceService) GetPublicKey(ctx context.Context, instanceID string) (string, error)

GetPublicKey retrieves the public key for signature verification. Returns an error if the instance is not found or is revoked.

func (*InstanceService) Register

func (s *InstanceService) Register(ctx context.Context, input RegisterInstanceInput) error

Register registers a new instance or updates an existing one. This is an unauthenticated endpoint - instances self-register with their public key.

func (*InstanceService) Revoke

func (s *InstanceService) Revoke(ctx context.Context, instanceID string) error

Revoke revokes an instance, preventing further snapshots.

type Period

type Period string

Period represents a time period for metrics queries.

const (
	Period24h Period = "24h"
	Period7d  Period = "7d"
	Period30d Period = "30d"
	Period3m  Period = "3m"
	Period1y  Period = "1y"
	PeriodAll Period = "all"
)

func ParsePeriod

func ParsePeriod(s string) Period

ParsePeriod parses a period string.

func (Period) Duration

func (p Period) Duration() time.Duration

Duration returns the time.Duration for the period.

type RegisterInstanceInput

type RegisterInstanceInput struct {
	InstanceID     string
	PublicKey      string
	AppName        string
	AppVersion     string
	DeploymentMode string
	Environment    string
	OSArch         string
}

RegisterInstanceInput holds the data needed to register an instance.

type SaveSnapshotInput

type SaveSnapshotInput struct {
	InstanceID string
	Timestamp  time.Time
	Metrics    json.RawMessage
}

SaveSnapshotInput holds the data needed to save a snapshot.

type SnapshotService

type SnapshotService struct {
	// contains filtered or unexported fields
}

SnapshotService handles snapshot-related use cases.

func NewSnapshotService

func NewSnapshotService(snapshotRepo ports.SnapshotRepository, instanceRepo ports.InstanceRepository) *SnapshotService

NewSnapshotService creates a new SnapshotService.

func (*SnapshotService) GetHistory

func (s *SnapshotService) GetHistory(ctx context.Context, instanceID string, limit int) ([]*domain.Snapshot, error)

GetHistory retrieves recent snapshots for an instance.

func (*SnapshotService) GetLatest

func (s *SnapshotService) GetLatest(ctx context.Context, instanceID string) (*domain.Snapshot, error)

GetLatest retrieves the most recent snapshot for an instance.

func (*SnapshotService) Save

Save validates and persists a snapshot from an instance. The instance must exist and not be revoked (verified by signature middleware).

Directories

Path Synopsis
Package ports defines the interfaces (ports) used by the application layer.
Package ports defines the interfaces (ports) used by the application layer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL