Documentation
¶
Index ¶
- type ApplicationService
- func (s *ApplicationService) CreateOrGet(ctx context.Context, appName string) (*domain.Application, error)
- func (s *ApplicationService) GetBySlug(ctx context.Context, slug string) (*domain.Application, error)
- func (s *ApplicationService) List(ctx context.Context, limit int) ([]*domain.Application, error)
- func (s *ApplicationService) RefreshAllStars(ctx context.Context) error
- func (s *ApplicationService) RefreshStars(ctx context.Context, slug string) error
- func (s *ApplicationService) Update(ctx context.Context, input UpdateApplicationInput) error
- type DashboardService
- func (s *DashboardService) GetActiveInstancesCount(ctx context.Context, appSlug string) (int, error)
- func (s *DashboardService) GetAggregatedMetric(ctx context.Context, appSlug, metricName string) (float64, error)
- func (s *DashboardService) GetCombinedStats(ctx context.Context, appSlug, metricName string) (float64, int, error)
- func (s *DashboardService) GetMetricsTimeSeries(ctx context.Context, appName string, period Period) (ports.MetricsTimeSeries, error)
- func (s *DashboardService) GetMostUsedVersion(ctx context.Context, appSlug string) (string, error)
- func (s *DashboardService) GetStats(ctx context.Context) (ports.DashboardStats, error)
- func (s *DashboardService) ListInstances(ctx context.Context, offset, limit int, appName, search string) ([]ports.InstanceSummary, error)
- type InstanceService
- func (s *InstanceService) Activate(ctx context.Context, instanceID string) error
- func (s *InstanceService) Delete(ctx context.Context, instanceID string) error
- func (s *InstanceService) GetPublicKey(ctx context.Context, instanceID string) (string, error)
- func (s *InstanceService) Register(ctx context.Context, input RegisterInstanceInput) error
- func (s *InstanceService) Revoke(ctx context.Context, instanceID string) error
- type Period
- type RegisterInstanceInput
- type SaveSnapshotInput
- type SnapshotService
- func (s *SnapshotService) GetHistory(ctx context.Context, instanceID string, limit int) ([]*domain.Snapshot, error)
- func (s *SnapshotService) GetLatest(ctx context.Context, instanceID string) (*domain.Snapshot, error)
- func (s *SnapshotService) Save(ctx context.Context, input SaveSnapshotInput) error
- type UpdateApplicationInput
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
func (s *ApplicationService) Update(ctx context.Context, input UpdateApplicationInput) error
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
GetMostUsedVersion returns the most commonly used version for an app.
func (*DashboardService) GetStats ¶
func (s *DashboardService) GetStats(ctx context.Context) (ports.DashboardStats, error)
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 ¶
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.
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 ¶
func (s *SnapshotService) Save(ctx context.Context, input SaveSnapshotInput) error
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
UpdateApplicationInput holds the data for updating an application.