Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • v1.23.2
  • v1.23.1
  • v1.23.0
  • v1.22.0
  • v1.21.1
  • v1.21.0
  • v1.20.3
  • v1.20.2
  • v1.20.1
  • v1.20.0
  • v1.19.4
  • v1.19.3
  • v1.19.2
  • v1.19.1
  • v1.19.0
  • v1.18.2
  • v1.18.1
  • v1.18.0
  • v1.17.0
  • v1.16.1
21 results

job-queues

  • Clone with SSH
  • Clone with HTTPS
  • 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.20+

    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)
        
    }
    

    Tests

    Run tests using:

    task test

    License

    This project is licensed under the AGPL-3.0 License - see the LICENSE.md file for details.

    Contact