A Clojure library that implements message queue with Datomic.
Leiningen coordinates:
[io.spinney/tiny-queue "1.0.2"]
The library provides wrap-background-job
function, which can be used to start the message queue.
This function requires your configuration in the form:
{:conn your-datomic-db-connection
:q d/q
:db d/db
:transact d/transact-async
:tiny-queue-processors {}}
Where d
is one of datomic.api
, datomic.client.api
. The most important part of the configuration is tiny-queue-processors
.
It should be a map with db idents as keys and functions as values.
To start message queue You should do following steps:
config
:(require '[datomic.api :as d])
(def conn (d/connect "your-datomic-db-uri"))
(def config
{:conn conn
:q d/q
:db d/db
:transact d/transact-async
:tiny-queue-processors {}})
tiny-queue
schema:(tq/create-schema config)
:db/ident
, second argument is a doc string):(tq/define-new-job config :qcommand/first-job "My first job!")
(defn first-job-processor [[snapshot job uuid]]
(println "Processing first job" uuid)
[])
tiny-queue-processors
:(def tiny-queue-processors {:qcommand/first-job first-job-processor})
wrap-background-job
:(require '[tiny-queue.core :as tq])
(def final-config (assoc config :tiny-queue-processors tiny-queue-processors))
(def background-processor (atom nil))
(reset! background-processor (future (wrap-background-job final-config 0)))
(tq/create-new-job final-config {:command :qcommand/first-job
:data "first-job-data"})
Copyright © 2022 Spinney
This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close