Skip to content
Snippets Groups Projects
Name Last commit Last update
.config/chglog
.gitlab/issue_templates
.idea
documentation/manual/de
nix
vendor
.envrc
.gitignore
.gitlab-ci.yml
.golangci.yaml
.mockery.yaml
CHANGELOG.md
CONTRIBUTING.md
LICENSE
README.md
config.go
database-1_test.go
database-2_test.go
database-3_test.go
database-4_test.go
database-5_test.go
database-6_test.go
database-7_test.go
database-8_test.go
database-logging.go
database-logging_test.go
database.go
database_test.go
errors.go
event-bus.go
event-bus_test.go
example_test.go
exit-codes.go
flake.lock
flake.nix
go.mod
go.sum
issue-1_test.go
job-generic.go
job-handler.go
job-log.go
job-queues.iml
job-stat.go
job-syncer.go
job-syncer_test.go
job.go
job_test.go
json-map.go
logger.go
logger_test.go
manager.go
manager_test.go
persistence.go
persistence_test.go
promise.go
promise_test.go
queue.go
queue_test.go
release.json
runnable-counter.go
runnable-counter_test.go
runnable-dummy.go
runnable-dummy_test.go
runnable-fileoperation.go
runnable-fileoperation_test.go
runnable-gorm.go
runnable-gorm_test.go
runnable-http.go
runnable-http_test.go
runnable-mail.go
runnable-mail_test.go
runnable-sftp.go
runnable-sftp_test.go
runnable-shell.go
runnable-shell_test.go
runnable.go
runnable_test.go
schedule-cron.go
schedule-delay.go
schedule-interval.go
schedule-interval_test.go
schedule-time.go
schedule-time_test.go
scheduler-event.go
scheduler-inotify.go
scheduler-instant.go
scheduler.go
scheduler_test.go
stat.go
stat_test.go
time-formats.go
topological-sort.go
topological-sort_test.go
util.go
worker.go
worker_test.go

Job Queues

Overview

These jobQueue library written in Go provides a simple interface for managing jobs and workers. It is designed to be used in a distributed environment where multiple workers can be assigned to a job queue. The library provides a Manager that can be used to manage workers, schedule jobs, and handle the state of the job queue.

Jobs can also be persisted to a database using Gorm.

The library also provides a Cron instance for scheduling jobs.

Getting Started

Prerequisites

  • Go 1.22+

Installation

go get -u gitlab.schukai.com/oss/libraries/go/services/job-queues

Usage

Import the package and create a new queue.

import "gitlab.schukai.com/oss/libraries/go/services/job-queues"


func main() {
var err error

m := jobqueue.NewManager()
w := jobqueue.NewWorker("worker1")
_ = m.AddWorker(w)

_ = m.Start()

job := jobqueue.Job{
ID: "job1",
}
scheduler := jobqueue.InstantScheduler{}

_ = m.ScheduleJob(job, &scheduler)

}

Development

Command Description
task check-code Run linters and static code analysis
task run-tests Run tests

License

This library is available under the AGPL-3.0 license for open-source projects. For commercial use, please reach out to us at sales@schukai.com.

Contact