Liking cljdoc? Tell your friends :D

pharmacist.result

Data structures and functions to work with the result of pharmacist.data-source fetch functions. A result is a map with the key :pharmacist.result/success? (a boolean) and any number of the below keys.

keydescription
:pharmacist.result/success?Boolean. Indicates successful retrieval
:pharmacist.result/dataThe resulting data from the fetch functions
:pharmacist.result/retryable?A boolean indicating whether this failure is worth retrying
:pharmacist.result/refreshOptional set of parameters that must be refreshed before retrying

The following keys are set by pharmacist.prescription/fill:

keydescription
:pharmacist.result/partial?true when the selection returned collection items, but the collection items are not yet available
:pharmacist.result/attemptsThe number of attempts made to fetch this source
:pharmacist.result/retrying?true if the result was a failure and Pharmacist intends to try it again
:pharmacist.result/raw-dataWhen the source has a schema that transforms ::pharmacist.result/data, this key has the unprocessed result
:pharmacist.result/timeout-afterThe number of milliseconds at which this source was considered timed out
:pharmacist.cache/cached-atTimestamp indicating when this result was originally cached
Data structures and functions to work with the result
  of [[pharmacist.data-source]] fetch functions. A result is a map with the key
  `:pharmacist.result/success?` (a boolean) and any number of the below keys.

| key                             | description |
| --------------------------------|-------------|
| `:pharmacist.result/success?`   | Boolean. Indicates successful retrieval
| `:pharmacist.result/data`       | The resulting data from the fetch functions
| `:pharmacist.result/retryable?` | A boolean indicating whether this failure is worth retrying
| `:pharmacist.result/refresh`    | Optional set of parameters that must be refreshed before retrying

  The following keys are set by [[pharmacist.prescription/fill]]:

| key                                | description |
| -----------------------------------|-------------|
| `:pharmacist.result/partial?`      | `true` when the selection returned collection items, but the collection items are not yet available
| `:pharmacist.result/attempts`      | The number of attempts made to fetch this source
| `:pharmacist.result/retrying?`     | `true` if the result was a failure and Pharmacist intends to try it again
| `:pharmacist.result/raw-data`      | When the source has a schema that transforms `::pharmacist.result/data`, this key has the unprocessed result
| `:pharmacist.result/timeout-after` | The number of milliseconds at which this source was considered timed out
| `:pharmacist.cache/cached-at`      | Timestamp indicating when this result was originally cached
raw docstring

errorclj/s

(error result error)

Create a failed result that caused an unexpected error - e.g. throwing an exception, not fulfilling fetch's contract, etc. result is whatever the original result was - possibly even an exception, and error is a map of:

keydescription
:messageA helpful message trying to help the developer understand the problem
:typeA keyword indicating the type of error
:reasonAn optional reason - one type of error may occur for different reasons
:upstreamThe exception that caused this error, if any
Create a failed result that caused an unexpected error - e.g. throwing an
  exception, not fulfilling fetch's contract, etc. `result` is whatever the
  original result was - possibly even an exception, and `error` is a map of:

| key         | description |
| ------------|-------------|
| `:message`  | A helpful message trying to help the developer understand the problem |
| `:type`     | A keyword indicating the type of error |
| `:reason`   | An optional reason - one type of error may occur for different reasons |
| `:upstream` | The exception that caused this error, if any |
sourceraw docstring

failureclj/s

(failure & [data config])

Create a failed result, optionally with data and additional keys for the result.

(require '[pharmacist.result :as result])

(result/failure {:message "Oops!"} {::result/retryable? true})
Create a failed result, optionally with data and additional keys for the result.

```clojure
(require '[pharmacist.result :as result])

(result/failure {:message "Oops!"} {::result/retryable? true})
```
sourceraw docstring

successclj/s

(success data & [config])

Create a successful result with data. Optionally provide further details about the result as config.

(require '[pharmacist.result :as result])

(result/success {:data "Yes"} {:my.app/custom-annotation 42})
;;=>
;; {::result/success? true
;;  ::result/data {:data "Yes"}
;;  :my.app/custom-annotation 42}
Create a successful result with data. Optionally provide further details about
  the result as `config`.

```clj
(require '[pharmacist.result :as result])

(result/success {:data "Yes"} {:my.app/custom-annotation 42})
;;=>
;; {::result/success? true
;;  ::result/data {:data "Yes"}
;;  :my.app/custom-annotation 42}
```
sourceraw docstring

success?clj/s

(success? result)

Returns true if this particular result was a success, as indicated by the :pharmacist.result/success? key

Returns true if this particular result was a success, as indicated by
the `:pharmacist.result/success?` key
sourceraw docstring

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

× close