{"id":20159796,"url":"https://github.com/diogok/batcher","last_synced_at":"2026-05-13T09:05:58.394Z","repository":{"id":62431292,"uuid":"47197329","full_name":"diogok/batcher","owner":"diogok","description":"Clojure operation buffer and batching by time and buffer size.","archived":false,"fork":false,"pushed_at":"2015-12-08T17:49:19.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T13:09:31.996Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diogok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-01T15:11:42.000Z","updated_at":"2015-12-01T15:12:00.000Z","dependencies_parsed_at":"2022-11-01T21:00:51.385Z","dependency_job_id":null,"html_url":"https://github.com/diogok/batcher","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diogok%2Fbatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diogok%2Fbatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diogok%2Fbatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diogok%2Fbatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diogok","download_url":"https://codeload.github.com/diogok/batcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241597604,"owners_count":19988279,"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":[],"created_at":"2024-11-14T00:10:25.950Z","updated_at":"2026-05-13T09:05:53.355Z","avatar_url":"https://github.com/diogok.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# batcher\n\nClojure library for batching operations on both buffer size limit and time limit, using channels.\n\nIt is a naive but working function.\n\n## Usage\n\nInclude the dependency:\n\n[![Clojars Project](http://clojars.org/batcher/latest-version.svg)](http://clojars.org/batcher)\n\nCreate a batch channel using the \"batcher\" function passing hashmap of options.\n\nThe options are all optional.\n\n```clojure\n{\n  :size 20\n  :time 1000\n  :fn (fn [buffer] nil)\n  :end (chan)\n  :out (chan)\n  :in (chan)\n}\n```\n\nIf you pass a function to fn, it will receive a vector of items each time the batch happens. It may be empty.\n\nIf you choose to provide your own in and out channels, they will be used and you can consume the batch buffer from the out channel. On end the channels will be closed and return nil. You should not consume the in channel, but you could use them in a tap or mult. \n\nThe end channel is closed and return nil after the internal input channel is closed, in case want to wait on it.\n\nThe size and time limit tell when to process the buffer into the out channel and/or function. Time limit is in millis, and size is the number of elements.\n\nThe batcher function return the input channel, that can be closed to end the process. On close the batcher also flushed the remaining buffer to the output channel and function.\n\n```clojure\n(use ['batcher.core])\n(require ['clojure.core.async :refer [\u003e! \u003e!! \u003c!! \u003c! go chan close! go-loop]])\n\n(defn callback \n [items] nil)\n\n(def batch (batcher {:size 50 :time 60000 :fn callback}))\n\n(\u003e!! batch {:foo \"bar\"})\n\n#_\"Several puts later\"\n(close! batcher)\n\n```\n\nThis batcher, that is just a channel, will call the callback function when it get 50 items or when 60 secs passes.\n\n## License\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiogok%2Fbatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiogok%2Fbatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiogok%2Fbatcher/lists"}