app

package
v0.0.0-...-8a20332 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleProcess

func HandleProcess(jobQueue *JobQueue) func(w http.ResponseWriter, r *http.Request)

func HandleStatus

func HandleStatus(jobQueue *JobQueue) func(w http.ResponseWriter, r *http.Request)

Types

type Job

type Job struct {
	ID     string `json:"id"`
	Status string `json:"status"`
	Result string `json:"result"`
}

Job represents a unit of work.

type JobQueue

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

JobQueue represents a queue for jobs.

func NewJobQueue

func NewJobQueue(redisClient *redis.Client) *JobQueue

NewJobQueue creates a new JobQueue.

func (*JobQueue) AddJob

func (jq *JobQueue) AddJob(job Job) error

AddJob adds a job to the queue with a TTL of 3 days.

func (*JobQueue) GetJob

func (jq *JobQueue) GetJob(id string) (Job, error)

GetJob retrieves a job by its ID.

func (*JobQueue) UpdateJob

func (jq *JobQueue) UpdateJob(job Job) error

UpdateJob updates the status of a job and refreshes its TTL.

type Worker

type Worker struct {
	ID int
	// contains filtered or unexported fields
}

Worker represents a worker that processes jobs.

func NewWorker

func NewWorker(id int, jobQueue *JobQueue) *Worker

NewWorker creates a new Worker.

func StartWorkerPool

func StartWorkerPool(queue *JobQueue, numWorkers int) []*Worker

StartWorkerPool starts a pool of workers.

func (*Worker) Start

func (w *Worker) Start()

Start starts the worker to process jobs.

func (*Worker) Stop

func (w *Worker) Stop()

Stop stops the worker.

Jump to

Keyboard shortcuts

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