{"id":20831080,"url":"https://github.com/mvdkleijn/go-simplequeue","last_synced_at":"2025-05-07T22:25:01.524Z","repository":{"id":47427646,"uuid":"398306380","full_name":"mvdkleijn/go-simplequeue","owner":"mvdkleijn","description":"Simple locking queue system with workers","archived":false,"fork":false,"pushed_at":"2024-02-19T15:51:50.000Z","size":51,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T14:57:18.301Z","etag":null,"topics":["go","golang","job","job-queue","library","locking","queue","simple","worker"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvdkleijn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"chaosmonkey","liberapay":"mvdkleijn"}},"created_at":"2021-08-20T14:39:40.000Z","updated_at":"2024-10-15T20:50:29.000Z","dependencies_parsed_at":"2024-01-12T21:45:43.616Z","dependency_job_id":"8cf1627e-faeb-44c3-88de-907fdf6f4472","html_url":"https://github.com/mvdkleijn/go-simplequeue","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdkleijn%2Fgo-simplequeue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdkleijn%2Fgo-simplequeue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdkleijn%2Fgo-simplequeue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdkleijn%2Fgo-simplequeue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvdkleijn","download_url":"https://codeload.github.com/mvdkleijn/go-simplequeue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252963309,"owners_count":21832483,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","job","job-queue","library","locking","queue","simple","worker"],"created_at":"2024-11-17T23:26:52.845Z","updated_at":"2025-05-07T22:25:01.503Z","avatar_url":"https://github.com/mvdkleijn.png","language":"Go","readme":"# go-simplequeue\n\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/mvdkleijn/go-simplequeue?style=for-the-badge)\n[![Codacy grade](https://img.shields.io/codacy/grade/3d4c22c400ea474c8fb69b4c9564484c?style=for-the-badge)](https://app.codacy.com/gh/mvdkleijn/go-simplequeue)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mvdkleijn/go-simplequeue?style=for-the-badge)](https://goreportcard.com/report/github.com/mvdkleijn/go-simplequeue) [![Liberapay patrons](https://img.shields.io/liberapay/patrons/mvdkleijn?style=for-the-badge)](https://liberapay.com/mvdkleijn/) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/O4O7H6C73)\n\nSimple locking queue system with workers.\n\nAlso see: \u003chttps://pkg.go.dev/code.vanderkleijn.net/go-simplequeue\u003e\n\n## Support\n\n- Go versions, see: https://endoflife.date/go\n\nSource code and issues: https://github.com/mvdkleijn/go-simplequeue\nAlso see: https://vanderkleijn.net/posts/announcing-go-simplequeue/\n\n\n## Usage / Example\n\n```golang\n// Define a job that conforms to the simplequeue.Job interface\ntype MyJob struct {\n    id int\n}\n\nfunc (mj *MyJob) ID() int64 {\n    return int64(mj.id)\n}\n\nfunc (mj *MyJob) Do() {\n    // Lets just pause the job for a little time\n    ms := time.Duration(rand.Intn(1000)+1) * time.Millisecond\n    time.Sleep(ms)\n    fmt.Printf(\"Job %d executing\\n\", mj.ID())\n}\n\n// Create some jobs for our test\nfunc createJobs(number int) []*MyJob {\n    jobs := make([]*MyJob, 0)\n\n    for i := 1; i \u003c= number; i++ {\n        jobs = append(jobs, \u0026MyJob{id: i})\n    }\n\n    return jobs\n}\n\n// Run our program\nfunc main() {\n    ctx := context.Background()\n\n    // How much we want of each\n    numWorkers := 15\n    numJobs := 200\n\n    // Create some jobs with a helper function\n    jobs := createJobs(numJobs)\n\n    // Create a queue\n    q := sq.CreateQueue(ctx)\n\n    // Initialize the workers\n    workers := sq.InitializeWorkers(ctx, numWorkers)\n\n    fmt.Printf(\"Number of workers in pool: %d\\n\", len(workers))\n    fmt.Printf(\"Number of jobs for queue: %d\\n\", len(jobs))\n\n    // Push the jobs onto the Queue\n    for _, job := range jobs {\n        q.Push(job)\n    }\n\n    // Process the queue with some workers\n    q.Process(ctx, workers)\n\n    // Show some stats afterwards\n    var totalJobsHandled int64 = 0\n    for _, w := range workers {\n        totalJobsHandled += w.Handled()\n\n        fmt.Printf(\"Worker %d processed a total of %d jobs\\n\", w.ID(), w.Handled())\n    }\n\n    fmt.Printf(\"Total jobs handled: %d\\n\", totalJobsHandled)\n    fmt.Printf(\"Total workers: %d\\n\", len(workers))\n}\n```\n\n# Licensing\n\nGo-simplequeue is made available under the [MPL-2.0](https://choosealicense.com/licenses/mpl-2.0/)\nlicense. The full details are available from the [LICENSE](/LICENSE) file.\n","funding_links":["https://ko-fi.com/chaosmonkey","https://liberapay.com/mvdkleijn","https://liberapay.com/mvdkleijn/","https://ko-fi.com/O4O7H6C73"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdkleijn%2Fgo-simplequeue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvdkleijn%2Fgo-simplequeue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdkleijn%2Fgo-simplequeue/lists"}