Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/boxuk/worker
Concurrent task manager
https://github.com/boxuk/worker
Last synced: about 2 months ago
JSON representation
Concurrent task manager
- Host: GitHub
- URL: https://github.com/boxuk/worker
- Owner: boxuk
- License: mit
- Created: 2013-04-10T10:38:32.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-05-27T21:38:15.000Z (over 11 years ago)
- Last Synced: 2024-09-16T19:43:47.537Z (4 months ago)
- Language: Clojure
- Size: 123 KB
- Stars: 1
- Watchers: 50
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Worker - Simultaneous Tasks!
This is a dirt simple library that tries to use futures to manage identical simultaneous tasks. The
motivation came from a JSON API app that could have potentially lengthy (5-10 second) requests to a
backend server that would produce identical results if all issued around the same time. Worker
allows them to be handled as a single task.## Usage
You can install Worker via [Clojars](https://clojars.org/boxuk/worker).
```clojure
(:use [worker.core :only [worker]])(worker
"a unique id"
(my-long-running-task 1 2 3))
```This will use the unique ID specified to check if this task is already running. If it isn't then it'll
create a future and store it, then blocking for the result.When another request comes in, if this task is still running it'll then just block on the same future.
Both tasks will then be returned together and the future forgotten.## Task IDs
The task ID used above was a string, but you can use vectors as well.
```clojure
(worker [:foo :bar :baz]
(some-task))
```This is available for extension via a multimethod.
```clojure
(defmulti make-id class)
```