maintenance

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

GORM-backed maintenance scheduling.

GormService runs background jobs for provider plugins against context-taking dependencies. It owns no tables: jobs stay in-memory (the lastRun/running maps). Auth flow state has no table: expiry is enforced by the dashboard readers. Expired dashboard sessions are removed hourly through the wired session cleanup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GormService added in v0.4.0

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

GormService runs background jobs for provider plugins against GORM-compatible dependencies. Scheduling semantics: bounded workers, overlap skips, startup bypass, auto-sync gate.

func NewGormService added in v0.4.0

func NewGormService(jobBackend PluginJobs, providerSource ProviderInventory, logger *slog.Logger) *GormService

NewGormService constructs a GORM-backed maintenance service with the default check interval. Construction performs no I/O. SetModelInfoService wires model metadata refresh for providers with config.models_auto_sync enabled.

func (*GormService) RunJob added in v0.4.0

func (s *GormService) RunJob(ctx context.Context, providerID, jobName string) error

RunJob triggers one job for one provider on demand (dashboard). Unknown jobs fail loudly; running jobs report busy.

func (*GormService) RunStartupRefresh added in v0.4.0

func (s *GormService) RunStartupRefresh(ctx context.Context)

RunStartupRefresh runs startup jobs synchronously. It never fails startup: every outcome logs inside the pass, and cancellation only stops launching new workers.

func (*GormService) SetModelInfoService added in v0.4.0

func (s *GormService) SetModelInfoService(refresher modelInfoRefresher)

SetModelInfoService wires model metadata refresh for providers with config.models_auto_sync enabled.

func (*GormService) SetSessionCleanup added in v0.6.9

func (s *GormService) SetSessionCleanup(cleanup func(ctx context.Context) error)

SetSessionCleanup wires expired-session removal into the tick.

func (*GormService) SetVirtualSyncer added in v0.4.0

func (s *GormService) SetVirtualSyncer(syncer VirtualSyncer)

SetVirtualSyncer wires managed virtual model rebuilds after a successful automatic model sync. A nil syncer skips the rebuild.

func (*GormService) Start added in v0.4.0

func (s *GormService) Start(ctx context.Context)

Start launches the maintenance loop in a background goroutine. It stops when ctx is cancelled.

func (*GormService) WithInterval added in v0.4.0

func (s *GormService) WithInterval(duration time.Duration) *GormService

WithInterval overrides the check interval (useful for testing).

type PluginJobs added in v0.4.0

type PluginJobs interface {
	Jobs(typeKey string) map[string]luaplugin.JobSpec
	RunJob(ctx context.Context, typeKey, jobName, reason, providerID string, providerConfig map[string]any) error
}

PluginJobs is the luaplugin surface the maintenance path needs: job schedules plus one job execution. The luaplugin Service satisfies it; the registry and RunJob signatures are storage-agnostic, so no luaplugin statement runs here.

type ProviderInventory added in v0.4.0

type ProviderInventory interface {
	Get(ctx context.Context, identifier string) (*models.ProviderInstance, error)
	List(ctx context.Context) ([]*models.ProviderInstance, error)
}

ProviderInventory is the provider surface the maintenance path needs: one row for manual triggers plus the full list for ticks. Signatures match the provider GORM service.

type VirtualSyncer added in v0.4.0

type VirtualSyncer interface {
	SyncProviderModels(ctx context.Context, providerID string) ([]virtual.ProviderVMGroup, error)
}

VirtualSyncer rebuilds managed virtual models from the warmed model cache after an automatic sync. The virtual GORM service satisfies it; sync failures log and continue like every other maintenance outcome.

Jump to

Keyboard shortcuts

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