app

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationService added in v1.2.0

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

ApplicationService handles application-related use cases.

func NewApplicationService added in v1.2.0

func NewApplicationService(
	repo ports.ApplicationRepository,
	github ports.GitHubService,
	logger *slog.Logger,
) *ApplicationService

NewApplicationService creates a new ApplicationService.

func (*ApplicationService) CreateOrGet added in v1.2.0

func (s *ApplicationService) CreateOrGet(ctx context.Context, appName string) (*domain.Application, error)

CreateOrGet creates a new application or returns an existing one by slug. This is used during instance registration to auto-create applications.

func (*ApplicationService) GetBySlug added in v1.2.0

func (s *ApplicationService) GetBySlug(ctx context.Context, slug string) (*domain.Application, error)

GetBySlug retrieves an application by its slug.

func (*ApplicationService) List added in v1.2.0

func (s *ApplicationService) List(ctx context.Context, limit int) ([]*domain.Application, error)

List retrieves all applications.

func (*ApplicationService) RefreshAllStars added in v1.2.0

func (s *ApplicationService) RefreshAllStars(ctx context.Context) error

RefreshAllStars refreshes GitHub stars for all applications that have a GitHub URL. Only refreshes if data is stale (based on Application.NeedsStarsRefresh).

func (*ApplicationService) RefreshStars added in v1.2.0

func (s *ApplicationService) RefreshStars(ctx context.Context, slug string) error

RefreshStars fetches fresh star count from GitHub for a specific application.

func (*ApplicationService) Update added in v1.2.0

Update updates an application's metadata.

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) GetActiveInstancesCount added in v1.2.0

func (s *DashboardService) GetActiveInstancesCount(ctx context.Context, appSlug string) (int, error)

GetActiveInstancesCount returns the count of active instances for an app.

func (*DashboardService) GetAggregatedMetric added in v1.2.0

func (s *DashboardService) GetAggregatedMetric(ctx context.Context, appSlug, metricName string) (float64, error)

GetAggregatedMetric sums a specific metric across all active instances of an app.

func (*DashboardService) GetCombinedStats added in v1.2.0

func (s *DashboardService) GetCombinedStats(ctx context.Context, appSlug, metricName string) (float64, int, error)

GetCombinedStats returns both an aggregated metric and instance count.

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) GetMostUsedVersion added in v1.2.0

func (s *DashboardService) GetMostUsedVersion(ctx context.Context, appSlug string) (string, error)

GetMostUsedVersion returns the most commonly used version for an app.

func (*DashboardService) GetStats

GetStats returns aggregated dashboard statistics.

func (*DashboardService) ListInstances

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

ListInstances returns instances with their latest metrics. offset and limit are used for pagination. appName filters by app name (empty = all apps). search filters by instance_id, version, environment, or deployment_mode.

type InstanceService

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

InstanceService handles instance-related use cases.

func NewInstanceService

func NewInstanceService(repo ports.InstanceRepository, appSvc *ApplicationService) *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) Delete added in v1.2.2

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

Delete permanently removes an instance and all its associated snapshots.

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).

type UpdateApplicationInput added in v1.2.0

type UpdateApplicationInput struct {
	Slug      string
	GitHubURL string
	LogoURL   string
}

UpdateApplicationInput holds the data for updating an application.

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