Liking cljdoc? Tell your friends :D

goose.client

Functions for executing job in async, scheduled or periodic manner.

Functions for executing job in async, scheduled or periodic manner.
raw docstring

default-optsclj

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

:queue : Destination where client produces to & worker consumes from.
Example : goose.defaults/default-queue

:retry-opts : Configuration for handling Job failure.
Example : goose.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*     : [[goose.defaults/default-queue]]

`:retry-opts` : Configuration for handling Job failure.\
*Example*     : [[goose.retry/default-opts]]\
[Error Handling & Retries wiki](https://github.com/nilenso/goose/wiki/Error-Handling-&-Retries)
sourceraw docstring

perform-asyncclj

(perform-async opts execute-fn-sym & args)

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

(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).
sourceraw docstring

perform-atclj

(perform-at opts instant execute-fn-sym & args)

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

(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)
sourceraw docstring

perform-batchclj

(perform-batch opts batch-opts execute-fn-sym args-coll)

Enqueues a collection of Jobs for execution in parallel, and tracks them as a single entity. Reports status of a batch via a callback when all Jobs have reached terminal state.

Args

client-opts : Map of :broker, :queue & :retry-opts.
Example : default-opts

batch-opts : Map of :callback-fn-sym, :linger-sec.
Example : goose.batch/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-coll : A sequential collection of args. Args must be represented as a sequential collection too. This collection is iterated upon for creating Batch-Jobs.
Number of Jobs in a Batch is equal to the number of elements in args-coll.
Given values must be serializable by ptaoussanis/nippy. Example : [[1] [2] [:foo :bar] [{:some :map}]]

Usage

(let [batch-opts goose.batch/default-opts
      ;; For single-arity functions
      args [1 2 3 4 5]
      args-coll (map list args)
      ;; For multi-arity or variadic functions
      args-coll (-> []
                    (goose.batch/construct-args :foo :bar :baz)
                    (goose.batch/construct-args :fizz :buzz))]
  (perform-batch client-opts batch-opts `send-emails args-coll))
Enqueues a collection of Jobs for execution in parallel,
 and tracks them as a single entity. Reports status of a batch
 via a callback when all Jobs have reached terminal state.

### Args
`client-opts`    : Map of `:broker`, `:queue` & `:retry-opts`.\
*Example*        : [[default-opts]]

`batch-opts`     : Map of `:callback-fn-sym`, `:linger-sec`.\
*Example*        : [[goose.batch/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-coll`      : A sequential collection of args. Args must be represented as a
sequential collection too. This collection is iterated upon for creating Batch-Jobs.\
Number of Jobs in a Batch is equal to the number of elements in args-coll.\
Given values must be serializable by `ptaoussanis/nippy`.
*Example*        : `[[1] [2] [:foo :bar] [{:some :map}]]`

### Usage
```Clojure
(let [batch-opts goose.batch/default-opts
      ;; For single-arity functions
      args [1 2 3 4 5]
      args-coll (map list args)
      ;; For multi-arity or variadic functions
      args-coll (-> []
                    (goose.batch/construct-args :foo :bar :baz)
                    (goose.batch/construct-args :fizz :buzz))]
  (perform-batch client-opts batch-opts `send-emails args-coll))
```

- [Batch Jobs wiki](https://github.com/nilenso/goose/wiki/Batch-Jobs)
sourceraw docstring

perform-everyclj

(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.

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

(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)
sourceraw docstring

perform-in-secclj

(perform-in-sec opts sec execute-fn-sym & args)

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

(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)
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close