{"id":20620280,"url":"https://github.com/wind-c/bqueue","last_synced_at":"2025-04-15T12:14:02.708Z","repository":{"id":65545574,"uuid":"594414532","full_name":"wind-c/bqueue","owner":"wind-c","description":"Time driven non-blocking and high-performance batch queue","archived":false,"fork":false,"pushed_at":"2023-01-28T14:42:50.000Z","size":14,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T12:13:45.626Z","etag":null,"topics":["batch","callback-functions","channel","context","golang","high-performance","non-blocking","queue","timer"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wind-c.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-28T13:37:55.000Z","updated_at":"2025-01-06T07:21:59.000Z","dependencies_parsed_at":"2023-02-15T17:01:44.620Z","dependency_job_id":null,"html_url":"https://github.com/wind-c/bqueue","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wind-c%2Fbqueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wind-c%2Fbqueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wind-c%2Fbqueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wind-c%2Fbqueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wind-c","download_url":"https://codeload.github.com/wind-c/bqueue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249067779,"owners_count":21207396,"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":["batch","callback-functions","channel","context","golang","high-performance","non-blocking","queue","timer"],"created_at":"2024-11-16T12:14:03.835Z","updated_at":"2025-04-15T12:14:02.670Z","avatar_url":"https://github.com/wind-c.png","language":"Go","readme":"`bqueue` [![Go Report Card](https://goreportcard.com/badge/github.com/wind-c/bqueue)](https://goreportcard.com/report/github.com/wind-c/bqueue) [![Build Status](https://travis-ci.org/wind-c/bqueue.svg?branch=master)](https://travis-ci.org/wind-c/bqueue) [![GoDoc Reference](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/wind-c/bqueue)\n=======\nA high-performance batch queue to process items at time intervals or when a batching limit is met.\u003cbr\u003e\nIt is implemented using the go standard library and does not import any third-party libraries.\n\n## Features\n- **Non-blocking enqueue** \u003cbr\u003e Queue up incoming items without blocking processing.\n\n- **Dispatching by periodic time intervals** \u003cbr\u003e Set a time interval and get batched items after time expires.\n\n- **Dispatching as soon as a batch limit is met**\u003cbr\u003e If a batch is filled before the time interval is up, dispatching is handled immediately.\n\n- **Supports channel and callback** \u003cbr\u003e You can read the OutQueue channel to get batch items, or you can use callback function. See Examples for details.\n\n- **Plain old Go channels** \u003cbr\u003e Implementation relies heavily on channels and is free of mutexes and other bookkeeping techniques.\n\n## Install\n```sh\n$ go get -u github.com/wind-c/bqueue\n```\n\n## Sample Usage\n\nDispatch a batch at 1 second intervals or as soon as a batching limit of 64 items is met，\nif the number of messages is large, increase MaxQueueSize.\nSee `examples/` for working code.\n\n```go\nimport (\n  \"fmt\"\n  \"log\"\n  \"time\"\n  \"github.com/wind-c/bqueue\"\n)\n\n// initialize\nb := bqueue.NewBatchQueue(\u0026bqueue.Options{\n  Interval:      time.Duration(1) * time.Second,\n  MaxBatchItems: 64,\n  MaxQueueSize:  1024,\n})\ndefer b.Stop()\ngo b.Start()\n\n// produce some messages\ngo func() {\n  for i:= 0; i \u003c 100; i++ {\n    m := fmt.Sprintf(\"message #%d\", i)\n    b.Enqueue(m)\n  }\n}()\n\n// consume the batch\nfor {\n  select {\n    case batch := \u003c-b.OutQueue:\n      for _, item := range batch {\n        s := item.(string)\n        // do whatever.\n        log.Print(s)\n      }\n  }\n}\n```\n\n## Contribute\nImprovements, fixes, and feedback are welcome.\n\n## Legal\nMIT license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwind-c%2Fbqueue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwind-c%2Fbqueue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwind-c%2Fbqueue/lists"}