jobs

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupJobs

func SetupJobs(manager *Manager, serverManager *server.Manager, client remote.Client)

SetupJobs registers all available job types with the manager

Types

type BackupCreateJob

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

BackupCreateJob handles backup creation operations

func (*BackupCreateJob) Execute

func (j *BackupCreateJob) Execute(ctx context.Context, reporter ProgressReporter) (interface{}, error)

func (*BackupCreateJob) GetID

func (j *BackupCreateJob) GetID() string

BackupCreateJob implementation

func (*BackupCreateJob) GetMessage

func (j *BackupCreateJob) GetMessage() string

func (*BackupCreateJob) GetProgress

func (j *BackupCreateJob) GetProgress() int

func (*BackupCreateJob) GetServerID

func (j *BackupCreateJob) GetServerID() string

WebSocketJob interface implementation for real-time backup status updates

func (*BackupCreateJob) GetType

func (j *BackupCreateJob) GetType() string

func (*BackupCreateJob) GetWebSocketEventData

func (j *BackupCreateJob) GetWebSocketEventData() map[string]interface{}

func (*BackupCreateJob) GetWebSocketEventType

func (j *BackupCreateJob) GetWebSocketEventType() string

func (*BackupCreateJob) Validate

func (j *BackupCreateJob) Validate() error

type BackupDeleteAllJob

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

BackupDeleteAllJob handles deletion of all backups and repository destruction

func (*BackupDeleteAllJob) Execute

func (j *BackupDeleteAllJob) Execute(ctx context.Context, reporter ProgressReporter) (interface{}, error)

func (*BackupDeleteAllJob) GetID

func (j *BackupDeleteAllJob) GetID() string

Job interface implementation

func (*BackupDeleteAllJob) GetMessage

func (j *BackupDeleteAllJob) GetMessage() string

func (*BackupDeleteAllJob) GetProgress

func (j *BackupDeleteAllJob) GetProgress() int

func (*BackupDeleteAllJob) GetServerID

func (j *BackupDeleteAllJob) GetServerID() string

WebSocketJob interface implementation

func (*BackupDeleteAllJob) GetType

func (j *BackupDeleteAllJob) GetType() string

func (*BackupDeleteAllJob) GetWebSocketEventData

func (j *BackupDeleteAllJob) GetWebSocketEventData() map[string]interface{}

func (*BackupDeleteAllJob) GetWebSocketEventType

func (j *BackupDeleteAllJob) GetWebSocketEventType() string

func (*BackupDeleteAllJob) Validate

func (j *BackupDeleteAllJob) Validate() error

type BackupDeleteJob

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

BackupDeleteJob handles backup deletion operations

func (*BackupDeleteJob) Execute

func (j *BackupDeleteJob) Execute(ctx context.Context, reporter ProgressReporter) (interface{}, error)

func (*BackupDeleteJob) GetID

func (j *BackupDeleteJob) GetID() string

BackupDeleteJob implementation

func (*BackupDeleteJob) GetMessage

func (j *BackupDeleteJob) GetMessage() string

func (*BackupDeleteJob) GetProgress

func (j *BackupDeleteJob) GetProgress() int

func (*BackupDeleteJob) GetServerID

func (j *BackupDeleteJob) GetServerID() string

WebSocketJob interface implementation for real-time backup status updates

func (*BackupDeleteJob) GetType

func (j *BackupDeleteJob) GetType() string

func (*BackupDeleteJob) GetWebSocketEventData

func (j *BackupDeleteJob) GetWebSocketEventData() map[string]interface{}

func (*BackupDeleteJob) GetWebSocketEventType

func (j *BackupDeleteJob) GetWebSocketEventType() string

func (*BackupDeleteJob) Validate

func (j *BackupDeleteJob) Validate() error

type BackupRestoreJob

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

BackupRestoreJob handles backup restoration operations

func (*BackupRestoreJob) Execute

func (j *BackupRestoreJob) Execute(ctx context.Context, reporter ProgressReporter) (interface{}, error)

func (*BackupRestoreJob) GetID

func (j *BackupRestoreJob) GetID() string

BackupRestoreJob implementation

func (*BackupRestoreJob) GetMessage

func (j *BackupRestoreJob) GetMessage() string

func (*BackupRestoreJob) GetProgress

func (j *BackupRestoreJob) GetProgress() int

func (*BackupRestoreJob) GetServerID

func (j *BackupRestoreJob) GetServerID() string

WebSocketJob interface implementation for real-time backup status updates

func (*BackupRestoreJob) GetType

func (j *BackupRestoreJob) GetType() string

func (*BackupRestoreJob) GetWebSocketEventData

func (j *BackupRestoreJob) GetWebSocketEventData() map[string]interface{}

func (*BackupRestoreJob) GetWebSocketEventType

func (j *BackupRestoreJob) GetWebSocketEventType() string

func (*BackupRestoreJob) Validate

func (j *BackupRestoreJob) Validate() error

type Instance

type Instance struct {
	Job       Job         `json:"job"`
	Status    Status      `json:"status"`
	Progress  int         `json:"progress"`
	Message   string      `json:"message"`
	Error     string      `json:"error"`
	Result    interface{} `json:"result"`
	CreatedAt time.Time   `json:"created_at"`
	UpdatedAt time.Time   `json:"updated_at"`
}

Instance wraps a Job implementation with execution metadata

type Job

type Job interface {
	// GetID returns the unique identifier for this job
	GetID() string

	// GetType returns the job type (e.g., "backup_create", "backup_delete")
	GetType() string

	// Execute runs the job and returns any result or error
	// The ProgressReporter is provided to allow real-time status updates
	Execute(ctx context.Context, reporter ProgressReporter) (interface{}, error)

	// Validate ensures the job data is valid before execution
	Validate() error

	// GetProgress returns current progress (0-100)
	GetProgress() int

	// GetMessage returns current status message
	GetMessage() string
}

Job represents a generic job that can be executed

func NewBackupCreateJob

func NewBackupCreateJob(data map[string]interface{}, serverManager *server.Manager, client remote.Client) (Job, error)

NewBackupCreateJob creates a new backup creation job

func NewBackupDeleteAllJob

func NewBackupDeleteAllJob(data map[string]interface{}, serverManager *server.Manager, client remote.Client) (Job, error)

NewBackupDeleteAllJob creates a new delete all backups job

func NewBackupDeleteJob

func NewBackupDeleteJob(data map[string]interface{}, serverManager *server.Manager, client remote.Client) (Job, error)

NewBackupDeleteJob creates a new backup deletion job

func NewBackupRestoreJob

func NewBackupRestoreJob(data map[string]interface{}, serverManager *server.Manager, client remote.Client) (Job, error)

NewBackupRestoreJob creates a new backup restoration job

type Manager

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

Manager handles job execution and lifecycle

func NewManager

func NewManager(workers int) *Manager

NewManager creates a new job manager

func (*Manager) CancelJob

func (m *Manager) CancelJob(jobID string) error

CancelJob cancels a running job

func (*Manager) CreateJob

func (m *Manager) CreateJob(jobType string, data map[string]interface{}) (string, error)

CreateJob creates and queues a new job for execution

func (*Manager) GetJob

func (m *Manager) GetJob(jobID string) (*Instance, bool)

GetJob returns specific job information

func (*Manager) RegisterJobType

func (m *Manager) RegisterJobType(jobType string, constructor func(data map[string]interface{}) (Job, error))

RegisterJobType registers a job constructor for a specific type

func (*Manager) SetClient

func (m *Manager) SetClient(client remote.Client)

SetClient sets the remote client for Panel notifications

func (*Manager) SetServerManager

func (m *Manager) SetServerManager(serverManager *server.Manager)

SetServerManager sets the server manager for WebSocket event publishing

func (*Manager) Start

func (m *Manager) Start()

Start begins processing jobs with workers

func (*Manager) UpdateJob

func (m *Manager) UpdateJob(jobID string, status Status, progress int, message string, result interface{}) error

UpdateJob updates job status, progress, and result

type ProgressReporter

type ProgressReporter interface {
	ReportProgress(progress int, message string)
	ReportStatus(status Status, message string)
}

ProgressReporter allows jobs to report progress updates automatically

type Status

type Status string

Status represents the current status of a job

const (
	StatusPending   Status = "pending"
	StatusRunning   Status = "running"
	StatusCompleted Status = "completed"
	StatusFailed    Status = "failed"
)

type WebSocketJob

type WebSocketJob interface {
	// GetServerID returns the server ID for WebSocket event targeting
	GetServerID() string

	// GetWebSocketEventType returns the event type for this job (e.g., "backup.status")
	GetWebSocketEventType() string

	// GetWebSocketEventData returns job-specific data to include in WebSocket events
	GetWebSocketEventData() map[string]interface{}
}

WebSocketJob is an optional interface for jobs that need WebSocket events

Jump to

Keyboard shortcuts

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