Functions for executing job in async, scheduled or periodic manner.
Functions for executing job in async, scheduled or periodic manner.
Map of sample configs for producing jobs.
:broker
: Message broker that transfers message from Producer to Consumer.
Given value must implement goose.broker/Broker
protocol.
Message Broker wiki
:queue
: Destination where client produces to & worker consumes from.
Example : [[d/default-queue]]
:retry-opts
: Configuration for handling Job failure.
Example : retry/default-opts
Error Handling & Retries wiki
Map of sample configs for producing jobs. ### Keys `:broker` : Message broker that transfers message from Producer to Consumer.\ Given value must implement [[goose.broker/Broker]] protocol.\ [Message Broker wiki](https://github.com/nilenso/goose/wiki/Message-Brokers) `:queue` : Destination where client produces to & worker consumes from.\ Example : [[d/default-queue]] `:retry-opts` : Configuration for handling Job failure.\ Example : [[retry/default-opts]]\ [Error Handling & Retries wiki](https://github.com/nilenso/goose/wiki/Error-Handling-&-Retries)
(perform-async opts execute-fn-sym & args)
Enqueues a function for async execution.
client-opts
: Map of :broker
, :queue
& :retry-opts
.
Example : default-opts
execute-fn-sym
: A fully-qualified function symbol called by worker.
Example : my-fn`,
ns-alias/my-fn,
'fully-qualified-ns/my-fn`
args
: Variadic values provided in given order when invoking execute-fn-sym
.
Given values must be serializable by ptaoussanis/nippy
.
(perform-async client-opts `send-emails "subject" "body" [:user-1 :user-2])
Enqueues a function for async execution. ### Args `client-opts` : Map of `:broker`, `:queue` & `:retry-opts`.\ Example : [[default-opts]] `execute-fn-sym` : A fully-qualified function symbol called by worker.\ Example : ```my-fn`, ```ns-alias/my-fn`, `'fully-qualified-ns/my-fn` `args` : Variadic values provided in given order when invoking `execute-fn-sym`.\ Given values must be serializable by `ptaoussanis/nippy`. ### Usage ```Clojure (perform-async client-opts `send-emails "subject" "body" [:user-1 :user-2]) ``` - [Getting Started wiki](https://github.com/nilenso/goose/wiki/Getting-Started).
(perform-at opts instant execute-fn-sym & args)
Schedules a function for execution at given date & time.
client-opts
: Map of :broker
, :queue
& :retry-opts
.
Example : default-opts
^Instant instant
: java.time.Instant
at which job should be executed.
execute-fn-sym
: A fully-qualified function symbol called by worker.
Example : my-fn`,
ns-alias/my-fn,
'fully-qualified-ns/my-fn`
args
: Variadic values provided in given order when invoking execute-fn-sym
.
Given values must be serializable by ptaoussanis/nippy
.
(let [instant (java.time.Instant/parse "2022-10-31T18:46:09.00Z")]
(perform-at client-opts instant `send-emails "subject" "body" [:user-1 :user-2]))
Schedules a function for execution at given date & time. ### Args `client-opts` : Map of `:broker`, `:queue` & `:retry-opts`.\ Example : [[default-opts]] `^Instant instant` : `java.time.Instant` at which job should be executed. `execute-fn-sym` : A fully-qualified function symbol called by worker.\ Example : ```my-fn`, ```ns-alias/my-fn`, `'fully-qualified-ns/my-fn` `args` : Variadic values provided in given order when invoking `execute-fn-sym`.\ Given values must be serializable by `ptaoussanis/nippy`. ### Usage ```Clojure (let [instant (java.time.Instant/parse "2022-10-31T18:46:09.00Z")] (perform-at client-opts instant `send-emails "subject" "body" [:user-1 :user-2])) ``` - [Scheduled Jobs wiki](https://github.com/nilenso/goose/wiki/Scheduled-Jobs)
(perform-every opts cron-opts execute-fn-sym & args)
Registers a function for periodic execution in cron-jobs style.
perform-every
is idempotent.
If a cron entry already exists with the same name, it will be overwritten with new data.
client-opts
: Map of :broker
, :queue
& :retry-opts
.
Example : default-opts
cron-opts
: Map of :cron-name
, :cron-schedule
, :timezone
:cron-name
(Mandatory)
:cron-schedule
(Mandatory)
:timezone
(Optional)
(java.time.ZoneId/getAvailableZoneIds)
execute-fn-sym
: A fully-qualified function symbol called by worker.
Example : my-fn`,
ns-alias/my-fn,
'fully-qualified-ns/my-fn`
args
: Variadic values provided in given order when invoking execute-fn-sym
.
Given values must be serializable by ptaoussanis/nippy
.
(let [cron-opts {:cron-name "my-periodic-job"
:cron-schedule "0 10 15 * *"
:timezone "US/Pacific"}]
(perform-every client-opts cron-opts `send-emails "subject" "body" [:user-1 :user-2]))
Registers a function for periodic execution in cron-jobs style.\ `perform-every` is idempotent.\ If a cron entry already exists with the same name, it will be overwritten with new data. ### Args `client-opts` : Map of `:broker`, `:queue` & `:retry-opts`.\ Example : [[default-opts]] `cron-opts` : Map of `:cron-name`, `:cron-schedule`, `:timezone` - `:cron-name` (Mandatory) - Unique identifier of a periodic job - `:cron-schedule` (Mandatory) - Unix-style schedule - `:timezone` (Optional) - Timezone for executing the Job at schedule - Acceptable timezones: `(java.time.ZoneId/getAvailableZoneIds)` - Defaults to system timezone `execute-fn-sym` : A fully-qualified function symbol called by worker.\ Example : ```my-fn`, ```ns-alias/my-fn`, `'fully-qualified-ns/my-fn` `args` : Variadic values provided in given order when invoking `execute-fn-sym`.\ Given values must be serializable by `ptaoussanis/nippy`. ### Usage ```Clojure (let [cron-opts {:cron-name "my-periodic-job" :cron-schedule "0 10 15 * *" :timezone "US/Pacific"}] (perform-every client-opts cron-opts `send-emails "subject" "body" [:user-1 :user-2])) ``` - [Periodic Jobs wiki](https://github.com/nilenso/goose/wiki/Periodic-Jobs)
(perform-in-sec opts sec execute-fn-sym & args)
Schedules a function for execution with a delay of given seconds.
client-opts
: Map of :broker
, :queue
& :retry-opts
.
Example : default-opts
sec
: Delay of Job execution in seconds.
execute-fn-sym
: A fully-qualified function symbol called by worker.
Example : my-fn`,
ns-alias/my-fn,
'fully-qualified-ns/my-fn`
args
: Variadic values provided in given order when invoking execute-fn-sym
.
Given values must be serializable by ptaoussanis/nippy
.
(perform-in-sec default-opts 300 `send-emails "subject" "body" [:user-1 :user-2])
Schedules a function for execution with a delay of given seconds. ### Args `client-opts` : Map of `:broker`, `:queue` & `:retry-opts`.\ Example : [[default-opts]] `sec` : Delay of Job execution in seconds. `execute-fn-sym` : A fully-qualified function symbol called by worker.\ Example : ```my-fn`, ```ns-alias/my-fn`, `'fully-qualified-ns/my-fn` `args` : Variadic values provided in given order when invoking `execute-fn-sym`.\ Given values must be serializable by `ptaoussanis/nippy`. ### Usage ```Clojure (perform-in-sec default-opts 300 `send-emails "subject" "body" [:user-1 :user-2]) ``` - [Scheduled Jobs wiki](https://github.com/nilenso/goose/wiki/Scheduled-Jobs)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close