-
Notifications
You must be signed in to change notification settings - Fork 11
Getting Started
akshat edited this page Oct 20, 2023
·
11 revisions
;;; Clojure CLI/deps.edn
com.nilenso/goose {:mvn/version "0.4.0"}
;;; Leiningen/Boot
[com.nilenso/goose "0.4.0"]
- Provide args to
perform-async
like you'd when callingmy-fn
- Args must be serializable by Nippy
- Nippy serialization can be extended to custom data types
(ns my-app
(:require
[goose.brokers.redis.broker :as redis]
[goose.client :as c]))
(defn my-fn
[arg1 arg2]
(println "my-fn called with" arg1 arg2))
(let [redis-producer (redis/new-producer redis/default-opts)
;; Along with Redis, Goose supports RabbitMQ as well.
client-opts (assoc c/default-opts :broker redis-producer)]
;; Supply a fully-qualified function symbol for enqueuing.
;; Args to perform-async are variadic.
(c/perform-async client-opts `my-fn "foo" :bar)
(c/perform-in-sec client-opts 900 `my-fn "foo" :bar))
(ns my-worker
(:require
[goose.brokers.redis.broker :as redis]
[goose.worker :as w]))
;;; 'my-app' namespace should be resolvable by worker.
(let [redis-consumer (redis/new-consumer redis/default-opts)
;; Along with Redis, Goose supports RabbitMQ as well.
worker-opts (assoc w/default-opts :broker redis-consumer)
worker (w/start worker-opts)]
;; When shutting down worker...
(w/stop worker)) ; Performs graceful shutsdown.
Refer to relevant wikis for Broker Config, Worker Config, Scheduling a Job, Error Handling & Retries, Middleware linked on the home page.
Goose Jobs can be managed using API as well.
Previous: Basic Setup Next: Message Brokers
Home | Getting Started | RabbitMQ | Redis | Error Handling | Monitoring | Production Readiness | Troubleshooting
Need help? Open an issue or ping us on #goose @Clojurians slack.