job

package
v0.0.0-...-98367f4 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

README

Job Module

The Job module provides a comprehensive job scheduling and execution system for HyperSpot, enabling asynchronous task management with queue-based processing, retry mechanisms, status tracking, and suspend/resume capabilities. It supports multi-tenant job execution across different queue types with configurable timeouts, retries, and logging.

Overview

The job module is built around a hierarchical structure:

Job Groups
├── Job Types (registered per group)
│   ├── Worker Callbacks
│   ├── Timeout & Retry Policies
│   └── Parameter Schemas
└── Job Queues (compute, maintenance, download)
    ├── Job Workers (configurable capacity)
    └── Job Instances
        ├── Status Management (waiting → running → completed/failed)
        ├── Progress Tracking
        ├── Parameter Handling
        └── Result Storage

Domain Model

Core Entities

JobGroup: Logical grouping of related job types

  • Name (Primary Key): Group identifier
  • Queue: Target queue name (compute/maintenance/download)
  • Description: Human-readable description

JobType: Template defining job behavior and constraints

  • TypeID (Primary Key): Unique type identifier
  • Group: Reference to JobGroup
  • Name: Display name
  • TimeoutSec: Default execution timeout
  • MaxRetries: Default retry limit
  • RetryDelaySec: Default delay between retries
  • Worker callbacks for initialization, execution, suspend/resume
  • Parameter schema definition

Job: Individual job instance

  • JobID (UUID): Unique job identifier
  • TenantID (UUID): Multi-tenant isolation
  • UserID (UUID): Job owner
  • IdempotencyKey (UUID): Prevents duplicate creation
  • Type: Reference to JobType
  • Status progression: init → waiting → running → final states
  • Progress tracking (0.0 to 1.0)
  • Parameter storage (JSON)
  • Result storage (JSON)
  • Error information
  • Timing metadata

JobQueue: Execution queue with worker pool

  • Queue types: compute (capacity: 1), maintenance (capacity: 5), download (capacity: 10)
  • Worker pool management
  • Waiting job queue
  • Running job tracking
  • Job cancellation support
Job Lifecycle
[Created] → [Waiting] → [Running] → [Completed/Failed/Canceled]
     ↓           ↓       ↓     ↓
  [Skipped]     [Suspended]  [Retrying] → [Running] → [Completed/Failed/Canceled]
                     ↓
                 [Resumed] → [Running] → [Completed/Failed/Canceled]

Features

Core Functionality
  • Multi-tenant job execution with proper isolation
  • Queue-based job processing with dedicated worker pools
  • Asynchronous job execution with progress tracking
  • Idempotency support to prevent duplicate job creation
  • Status management with comprehensive state transitions
  • Retry mechanisms with configurable delays and limits
  • Suspend/resume capabilities for long-running jobs
  • Timeout handling with automatic job termination
  • Progress reporting with real-time updates
  • Result storage with JSON serialization
  • Comprehensive API with REST endpoints for all operations
Job Status Management
  • Initial States: initializing, waiting, resuming
  • Running States: running, canceling, suspending, locked
  • Intermediate States: suspended
  • Final States: skipped, canceled, failed, timeout, completed
Queue Types
  • Compute Queue: Single-threaded execution for CPU-intensive tasks (capacity: 1)
  • Maintenance Queue: Multi-threaded for system maintenance tasks (capacity: 5)
  • Download Queue: High-concurrency for download operations (capacity: 10)
Worker Callbacks
  • WorkerInitCallback: Called on job start or resume
  • WorkerExecutionCallback: Main job execution logic
  • WorkerStateUpdateCallback: Optional status update notifications
  • WorkerSuspendCallback: Called before job suspension
  • WorkerResumeCallback: Called after job resume

Configuration Settings

The job module supports configuration through the config.yaml file under the job_logger section for logging settings. Job-specific configurations are handled through JobType registration and individual job parameters.

Job Type Configuration

Job types are registered programmatically with the following parameters:

  • Group: Associated JobGroup
  • Name: Display name
  • Description: Job type description
  • Timeout: Default execution timeout
  • RetryDelay: Default delay between retries
  • MaxRetries: Default maximum retry attempts
  • WorkerIsSuspendable: Whether jobs can be suspended/resumed
  • Params: Parameter schema for validation
Job Instance Configuration

Individual jobs can override defaults:

  • TimeoutSec: Custom timeout for this job
  • MaxRetries: Custom retry limit for this job
  • RetryDelaySec: Custom retry delay for this job

Logging Configuration

job_logger:
  console_level: "info"     # Console log level
  file_level: "debug"       # File log level
  file: "logs/job.log"      # Log file path
  max_size_mb: 1000         # Max log file size before rotation
  max_backups: 3            # Number of backup log files to keep
  max_age_days: 28          # Max age of log files before deletion

API Endpoints

Job Management
Schedule Job
curl -X POST /jobs \
  -H "Content-Type: application/json" \
  -d '{
    "type": "job_type_id",
    "idempotency_key": "uuid",
    "params": {}
  }'
List Jobs
curl -X GET "/jobs?page=1&limit=10&status=running,completed&order=-scheduled_at"
Get Job
curl -X GET /jobs/{job_id}
Cancel Job
curl -X POST /jobs/{job_id}/cancel
Suspend Job
curl -X POST /jobs/{job_id}/suspend
Resume Job
curl -X POST /jobs/{job_id}/resume
Delete Job
curl -X DELETE /jobs/{job_id}
Job Types
List Job Types
curl -X GET "/job-types?page=1&limit=10"
Get Job Type
curl -X GET /job-types/{job_type_id}
Job Groups
List Job Groups
curl -X GET "/job-groups?page=1&limit=10"
Get Job Group
curl -X GET /job-groups/{job_group_id}

Database Schemas

Job Table
jobs:
  job_id           UUID (indexed, primary key)
  tenant_id        UUID (indexed)
  user_id          UUID (indexed)
  idempotency_key  UUID (indexed)
  type             VARCHAR (indexed)
  scheduled_at_ms  BIGINT (indexed)
  updated_at_ms    BIGINT (indexed)
  started_at_ms    BIGINT (indexed)
  eta_ms           BIGINT (indexed)
  locked_by        UUID (indexed)
  progress         FLOAT
  progress_details TEXT
  status           VARCHAR (indexed)
  details          TEXT
  timeout_sec      INTEGER
  max_retries      INTEGER
  retry_delay_sec  INTEGER
  retries          INTEGER
  error            TEXT
  result           TEXT
  params           TEXT (JSON)
JobType Table
job_types:
  type_id          VARCHAR (primary key)
  description      TEXT
  group_name       VARCHAR (foreign key)
  name             VARCHAR
  timeout_sec      INTEGER
  max_retries      INTEGER
  retry_delay_sec  INTEGER
JobGroup Table
job_groups:
  name            VARCHAR (primary key)
  queue_name      VARCHAR
  description     TEXT

Dependencies

The job module serves as a foundation for other modules that implement specific job types:

  • benchmark: Performance benchmarking jobs
  • benchmark_hw: Hardware benchmark jobs
  • benchmark_llm: LLM benchmarking jobs
  • dataset: Data processing jobs
  • models_registry: Model management jobs
  • test_module: Testing and validation jobs

Documentation

Index

Constants

View Source
const (
	// Initial states
	StatusInit     = "initializing"
	StatusWaiting  = "waiting"
	StatusResuming = "resuming"

	// Running states
	StatusRunning    = "running"
	StatusCanceling  = "canceling"  // still running, but will be canceled
	StatusSuspending = "suspending" // still running, but will be suspended
	StatusLocked     = "locked"     // almost like running, but just indicates it's locked by another job

	// Intermediate states
	StatusSuspended = "suspended" // dequeued from the 'running' queue

	// Final immutable states
	StatusSkipped   = "skipped"
	StatusCanceled  = "canceled"
	StatusFailed    = "failed"
	StatusTimedOut  = "timeout"
	StatusCompleted = "completed"
)
View Source
const JobGroupSeparator = ":"

Variables

This section is empty.

Functions

func JECancelJob

func JECancelJob(ctx context.Context, jobID uuid.UUID, reason error) errorx.Error

func JEDeleteJob

func JEDeleteJob(ctx context.Context, jobID uuid.UUID, reason error) errorx.Error

func JEResumeJob

func JEResumeJob(ctx context.Context, jobID uuid.UUID) errorx.Error

func JEScheduleJob

func JEScheduleJob(ctx context.Context, job *JobObj) errorx.Error

func JESuspendJob

func JESuspendJob(ctx context.Context, jobID uuid.UUID) errorx.Error

func JEWaitJob

func JEWaitJob(ctx context.Context, jobID uuid.UUID, timeoutSec time.Duration) errorx.Error

func RegisterJobGroup

func RegisterJobGroup(group *JobGroup)

func ResumeJobsOnServerStart

func ResumeJobsOnServerStart(ctx context.Context) error

ResumeJobsOnServerStart finds all jobs in initializing, waiting, running, and locked states and resumes them. This function is intended to be called during server startup to catch up any jobs that might have been left in an inconsistent state due to a previous server shutdown. Jobs are processed in batches of 50 to avoid loading too many jobs into memory at once.

Types

type Job

type Job struct {
	JobID           uuid.UUID `json:"id" gorm:"index"`
	TenantID        uuid.UUID `json:"tenant_id" gorm:"index"`
	UserID          uuid.UUID `json:"user_id" gorm:"index"`
	IdempotencyKey  uuid.UUID `json:"idempotency_key" gorm:"index"`
	Type            string    `json:"type" gorm:"index"`
	TypePtr         *JobType  `json:"-" gorm:"-"`
	ScheduledAtMs   int64     `json:"scheduled_at" gorm:"index" doc:"unix timestamp in milliseconds"`
	UpdatedAtMs     int64     `json:"updated_at" gorm:"index" doc:"unix timestamp in milliseconds"`
	StartedAtMs     int64     `json:"started_at" gorm:"index" doc:"unix timestamp in milliseconds"`
	ETAMs           int64     `json:"eta" gorm:"index" readOnly:"true" doc:"unix timestamp in milliseconds"`
	LockedBy        uuid.UUID `json:"locked_by" gorm:"index" readOnly:"true"`
	Progress        float32   `json:"progress" readOnly:"true"`
	ProgressDetails string    `json:"progress_details" readOnly:"true"`
	Status          JobStatus `json:"status" gorm:"index" readOnly:"true"`
	Details         string    `json:"details"`

	TimeoutSec    int `json:"timeout_sec,omitempty"` // Default is taken from JobType
	MaxRetries    int `json:"max_retries,omitempty"` // Default is taken from JobType
	RetryDelaySec int `json:"retry_delay_sec,omitempty"`

	Retries int `json:"retries" readOnly:"true"` // Track current retry count

	Error     string      `json:"error,omitempty" readOnly:"true"`
	Result    string      `json:"result,omitempty" readOnly:"true"`
	Params    string      `json:"params,omitempty"` // job parameters as a JSON string
	ParamsPtr interface{} `json:"-" gorm:"-"`       // job parameters as a struct

}

JobIface is used for API and DB interfaces, it has exported fields for proper serialization

type JobAPI

type JobAPI struct{}

func NewJobAPI

func NewJobAPI() *JobAPI

NewJobAPI creates and returns a new instance of JobAPI.

func (*JobAPI) APICancelJob

func (j *JobAPI) APICancelJob(ctx context.Context, input *struct {
	JobID string `path:"job_id"`
}) (*JobAPIResponse, error)

func (*JobAPI) APIDeleteJob

func (j *JobAPI) APIDeleteJob(ctx context.Context, input *struct {
	JobID string `path:"job_id"`
}) (*struct{}, error)

func (*JobAPI) APIGetJob

func (j *JobAPI) APIGetJob(ctx context.Context, input *struct {
	JobID string `path:"job_id"`
}) (*JobAPIResponse, error)

func (*JobAPI) APIGetJobGroup

func (j *JobAPI) APIGetJobGroup(ctx context.Context, input *struct {
	Name string `path:"job_group_id"`
}) (*JobGroupAPIResponse, error)

func (*JobAPI) APIGetJobType

func (j *JobAPI) APIGetJobType(ctx context.Context, input *struct {
	JobTypeID string `path:"job_type_id"`
}) (*JobTypeAPIResponse, error)

func (*JobAPI) APIListJobGroups

func (j *JobAPI) APIListJobGroups(ctx context.Context, input *ListJobGroupsAPIRequest) (*ListJobGroupsAPIResponse, error)

func (*JobAPI) APIListJobTypes

func (j *JobAPI) APIListJobTypes(ctx context.Context, request *api.PageAPIRequest) (*ListJobTypesAPIResponse, error)

func (*JobAPI) APIListJobs

func (j *JobAPI) APIListJobs(ctx context.Context, input *ListJobsAPIRequest) (*ListJobsAPIResponse, error)

func (*JobAPI) APIResumeJob

func (j *JobAPI) APIResumeJob(ctx context.Context, input *struct {
	JobID string `path:"job_id"`
}) (*JobAPIResponse, error)

func (*JobAPI) APIScheduleJob

func (j *JobAPI) APIScheduleJob(ctx context.Context, input *struct {
	Body struct {
		Type           string      `json:"type"`
		IdempotencyKey string      `json:"idempotency_key"`
		Params         interface{} `json:"params"`
	}
}) (*JobAPIResponse, error)

func (*JobAPI) APISuspendJob

func (j *JobAPI) APISuspendJob(ctx context.Context, input *struct {
	JobID string `path:"job_id"`
}) (*JobAPIResponse, error)

func (*JobAPI) JobGroupToAPIResponse

func (j *JobAPI) JobGroupToAPIResponse(jobGroup *JobGroup) *JobGroupAPIResponse

func (*JobAPI) JobToAPIResponse

func (j *JobAPI) JobToAPIResponse(job *JobObj) *JobAPIResponse

func (*JobAPI) JobTypeToAPIResponse

func (j *JobAPI) JobTypeToAPIResponse(jobType *JobType) *JobTypeAPIResponse

type JobAPIResponse

type JobAPIResponse struct {
	Body JobAPIResponseItem `json:"body"`
}

type JobAPIResponseItem

type JobAPIResponseItem Job

type JobGroup

type JobGroup struct {
	Name        string       `json:"name" gorm:"primaryKey"`
	Queue       JobQueueName `json:"queue_name"`
	Description string       `json:"description"`
}

func GetJobGroup

func GetJobGroup(name string) (*JobGroup, bool)

func GetJobGroups

func GetJobGroups(ctx context.Context, pageRequest *api.PageAPIRequest) []*JobGroup

type JobGroupAPIResponse

type JobGroupAPIResponse struct {
	Body JobGroupAPIResponseItem `json:"body"`
}

type JobGroupAPIResponseItem

type JobGroupAPIResponseItem JobGroup

type JobObj

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

JobObj has unexported fields and getter/setter APIs It is used for internal job operations and object safety

func JEGetJob

func JEGetJob(ctx context.Context, jobID uuid.UUID) (*JobObj, errorx.Error)

func JEGetJobByIdempotencyKey

func JEGetJobByIdempotencyKey(ctx context.Context, idempotencyKey uuid.UUID) (*JobObj, errorx.Error)

func ListJobs

func ListJobs(ctx context.Context, pageRequest *api.PageAPIRequest, status string) ([]*JobObj, error)

func NewJob

func NewJob(
	ctx context.Context,
	idempotencyKey uuid.UUID,
	jobType *JobType,
	paramsStr string,
) (*JobObj, error)

func (*JobObj) CheckStatusTransition

func (j *JobObj) CheckStatusTransition(desiredStatus JobStatus) (bool, error)

CheckStatusTransition implements safe job transition checks for concurrent job operations. Returns true/false if we need to update status and error in case of false

func (*JobObj) GetETA

func (j *JobObj) GetETA() int64

func (*JobObj) GetError

func (j *JobObj) GetError() string

func (*JobObj) GetIdempotencyKey

func (j *JobObj) GetIdempotencyKey() uuid.UUID

func (*JobObj) GetJobID

func (j *JobObj) GetJobID() uuid.UUID

func (*JobObj) GetLockedBy

func (j *JobObj) GetLockedBy() uuid.UUID

func (*JobObj) GetMaxRetries

func (j *JobObj) GetMaxRetries() int

func (*JobObj) GetParams

func (j *JobObj) GetParams() string

func (*JobObj) GetParamsPtr

func (j *JobObj) GetParamsPtr() interface{}

func (*JobObj) GetProgress

func (j *JobObj) GetProgress() float32

func (*JobObj) GetQueue

func (j *JobObj) GetQueue() JobQueueName

func (*JobObj) GetRetries

func (j *JobObj) GetRetries() int

func (*JobObj) GetRetryDelay

func (j *JobObj) GetRetryDelay() time.Duration

func (*JobObj) GetScheduledAt

func (j *JobObj) GetScheduledAt() int64

func (*JobObj) GetStartedAt

func (j *JobObj) GetStartedAt() int64

func (*JobObj) GetStatus

func (j *JobObj) GetStatus() JobStatus

func (*JobObj) GetStatusErrorProgressSuccess

func (j *JobObj) GetStatusErrorProgressSuccess() (string, string, float32, bool)

func (*JobObj) GetTenantID

func (j *JobObj) GetTenantID() uuid.UUID

func (*JobObj) GetTimeoutSec

func (j *JobObj) GetTimeoutSec() time.Duration

func (*JobObj) GetType

func (j *JobObj) GetType() string

func (*JobObj) GetTypePtr

func (j *JobObj) GetTypePtr() *JobType

func (*JobObj) GetUserID

func (j *JobObj) GetUserID() uuid.UUID

func (*JobObj) Log

func (j *JobObj) Log(level logging.Level, msg string, args ...interface{})

func (*JobObj) LogDebug

func (j *JobObj) LogDebug(msg string, args ...interface{})

func (*JobObj) LogError

func (j *JobObj) LogError(msg string, args ...interface{})

Job logs

func (*JobObj) LogInfo

func (j *JobObj) LogInfo(msg string, args ...interface{})

Job logs

func (*JobObj) LogTrace

func (j *JobObj) LogTrace(msg string, args ...interface{})

Job logs

func (*JobObj) LogWarn

func (j *JobObj) LogWarn(msg string, args ...interface{})

Job logs

func (*JobObj) SetLockedBy

func (j *JobObj) SetLockedBy(ctx context.Context, lockedBy uuid.UUID) error

func (*JobObj) SetProgress

func (j *JobObj) SetProgress(ctx context.Context, progress float32) error

func (*JobObj) SetResult

func (j *JobObj) SetResult(ctx context.Context, result interface{}) error

func (*JobObj) SetRetryPolicy

func (j *JobObj) SetRetryPolicy(retryDelay time.Duration, maxRetries int, timeout time.Duration) error

func (*JobObj) SetSkipped

func (j *JobObj) SetSkipped(ctx context.Context, reason string) error

func (*JobObj) SetUnlocked

func (j *JobObj) SetUnlocked(ctx context.Context) error

type JobQueue

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

---------------------------------------------------------------------- JobQueue encapsulates all queue‐specific logic.

func GetJobQueue

func GetJobQueue(queueName JobQueueName) (*JobQueue, error)

func NewJobQueue

func NewJobQueue(name JobQueueName, capacity int) *JobQueue

NewJobQueue creates a new JobQueue.

func RegisterJobQueue

func RegisterJobQueue(queueName JobQueueName, capacity int) (*JobQueue, error)

func (*JobQueue) AddJob

func (q *JobQueue) AddJob(job *JobObj)

AddJob adds a new job to the waiting list.

func (*JobQueue) AddRunningJob

func (q *JobQueue) AddRunningJob(job *JobObj)

AddRunningJob records that a job is now running.

func (*JobQueue) GetNextJob

func (q *JobQueue) GetNextJob() *JobObj

GetNextJob returns the next waitingjob. If no jobs are waiting, returns nil.

func (*JobQueue) RemoveRunningJob

func (q *JobQueue) RemoveRunningJob(jobID uuid.UUID)

RemoveRunningJob removes a job from the running map.

type JobQueueName

type JobQueueName string

---------------------------------------------------------------------- Define JobQueueName type (string alias) for queues.

const (
	JobQueueCompute     JobQueueName = "compute"
	JobQueueMaintenance JobQueueName = "maintenance"
	JobQueueDownload    JobQueueName = "download"
)

type JobStatus

type JobStatus string

JobStatus represents the current status of a job

const (
	// Initial states
	JobStatusInit     JobStatus = JobStatus(StatusInit)
	JobStatusWaiting  JobStatus = JobStatus(StatusWaiting)
	JobStatusResuming JobStatus = JobStatus(StatusResuming)

	// Running states
	JobStatusRunning    JobStatus = JobStatus(StatusRunning)
	JobStatusCanceling  JobStatus = JobStatus(StatusCanceling)
	JobStatusSuspending JobStatus = JobStatus(StatusSuspending)
	JobStatusLocked     JobStatus = JobStatus(StatusLocked)

	// Intermediate states
	JobStatusSuspended JobStatus = JobStatus(StatusSuspended)

	// Final immutable states
	JobStatusSkipped   JobStatus = JobStatus(StatusSkipped)
	JobStatusCanceled  JobStatus = JobStatus(StatusCanceled)
	JobStatusFailed    JobStatus = JobStatus(StatusFailed)
	JobStatusTimedOut  JobStatus = JobStatus(StatusTimedOut)
	JobStatusCompleted JobStatus = JobStatus(StatusCompleted)
)

type JobType

type JobType struct {
	TypeID                    string                       `json:"type_id" gorm:"primaryKey"`
	Description               string                       `json:"description"`
	Group                     string                       `json:"group"`
	GroupPtr                  *JobGroup                    `json:"-" gorm:"foreignKey:Group;references:Name"`
	Name                      string                       `json:"name"`
	TimeoutSec                int                          `json:"timeout_sec"`
	MaxRetries                int                          `json:"max_retries"`     // Maximum allowed retries
	RetryDelaySec             int                          `json:"retry_delay_sec"` // Delay between retries
	Params                    interface{}                  `json:"params" gorm:"-"`
	ParamsSchema              string                       `json:"params_schema" gorm:"-"`
	WorkerInitCallback        JobWorkerInitCallback        `json:"-" gorm:"-"`           // called within synchronous API call for job creation
	WorkerExecutionCallback   JobWorkerExecutionCallback   `json:"-" gorm:"-"`           // called in a go-routine as asynchronous job worker
	WorkerStateUpdateCallback JobWorkerStateUpdateCallback `json:"-" gorm:"-"`           // optional callback for status update, called from job execution worker
	WorkerSuspendCallback     JobWorkerSuspendCallback     `json:"-" gorm:"-"`           // optional callback for job suspension, called synchronously via API
	WorkerResumeCallback      JobWorkerResumeCallback      `json:"-" gorm:"-"`           // optional callback for job resume, called synchronously via API
	WorkerIsSuspendable       bool                         `json:"suspendable" gorm:"-"` // whether the job can be suspended/resumed
}

func GetJobType

func GetJobType(type_id string) (*JobType, bool)

func GetJobTypes

func GetJobTypes(ctx context.Context, pageRequest *api.PageAPIRequest) []*JobType

func RegisterJobType

func RegisterJobType(params JobTypeParams) *JobType

type JobTypeAPIResponse

type JobTypeAPIResponse struct {
	Body JobTypeAPIResponseItem `json:"body"`
}

type JobTypeAPIResponseItem

type JobTypeAPIResponseItem JobType

type JobTypeParams

type JobTypeParams struct {
	Group                     *JobGroup
	Name                      string
	Description               string
	Params                    interface{}
	WorkerInitCallback        JobWorkerInitCallback        // Initial job initialisation callback that is called on job start or resume
	WorkerExecutionCallback   JobWorkerExecutionCallback   // main worker callback that is called on job start or after resume
	WorkerStateUpdateCallback JobWorkerStateUpdateCallback // optional callback for linked objects state updates
	WorkerSuspendCallback     JobWorkerSuspendCallback     // optional callback called before job suspend
	WorkerResumeCallback      JobWorkerResumeCallback      // optional callback called after job resume, but before InitCallback
	WorkerIsSuspendable       bool                         // if true, the job can be suspended and resumed
	Timeout                   time.Duration
	RetryDelay                time.Duration
	MaxRetries                int
}

type JobWorker

type JobWorker any

type JobWorkerExecutionCallback

type JobWorkerExecutionCallback func(ctx context.Context, worker JobWorker, progress chan<- float32) error

JobWorkerExecutionCallback is a callback function for target worker execution. It run asynchronously in a dedicated go-routine, if error is returned then the job will be marked as failed. Otherwise it will be marked as completed successfully. This callback is called when the job is first started and again after resume. The progress channel is used to report progress updates to the job executor. On resume, the worker is responsible for setting the job progress to the last reported value.

type JobWorkerInitCallback

type JobWorkerInitCallback func(ctx context.Context, job *JobObj) (JobWorker, errorx.Error)

JobWorkerInitCallback is a callback function for job paramemeter initialisation. The function returns target worker object associated with current job and an error if any. It's being called from the synchronous API handler creating the job, so if error is returned, the job creation will fail

type JobWorkerResumeCallback

type JobWorkerResumeCallback func(ctx context.Context, job *JobObj) (JobWorker, errorx.Error)

A callback function for job resume after suspension, called from syncrhonous API handler If error is returned the resume operation will fail.

type JobWorkerStateUpdateCallback

type JobWorkerStateUpdateCallback func(ctx context.Context, job *JobObj) error

JobWorkerStateUpdateCallback is a callback function that updates target worker properties, such as Progress, Status, Error and Success

type JobWorkerSuspendCallback

type JobWorkerSuspendCallback func(ctx context.Context, job *JobObj) errorx.Error

A callback function for job suspension, called from syncrhonous API handler. If error is returned the suspend operation will fail.

type JobsExecutor

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

---------------------------------------------------------------------- JobsExecutor simply routes jobs into their proper queue.

type ListJobGroupsAPIRequest

type ListJobGroupsAPIRequest struct {
	api.PageAPIRequest
}

type ListJobGroupsAPIResponse

type ListJobGroupsAPIResponse struct {
	Body struct {
		api.PageAPIResponse
		JobGroups []JobGroupAPIResponseItem `json:"job_groups"`
	} `json:"body"`
}

type ListJobTypesAPIResponse

type ListJobTypesAPIResponse struct {
	Body struct {
		api.PageAPIResponse
		JobTypes []JobTypeAPIResponseItem `json:"job_types"`
	} `json:"body"`
}

type ListJobsAPIRequest

type ListJobsAPIRequest struct {
	api.PageAPIRequest
	Status string `query:"status" doc:"Filter by status, comma separated list of statuses is supported"`
}

type ListJobsAPIResponse

type ListJobsAPIResponse struct {
	Body struct {
		api.PageAPIResponse
		Jobs []JobAPIResponseItem `json:"jobs"`
	} `json:"body"`
}

Jump to

Keyboard shortcuts

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