Liking cljdoc? Tell your friends :D

commando.impl.utils


*command-map-spec-registry*clj/s

Dynamic variable what keep the state of processed :registry value from status-map

Dynamic variable what keep the state of processed
`:registry` value from `status-map`
sourceraw docstring

*execute-config*clj/s

Dynamic configuration for commando/execute behavior.

  • :debug-result (boolean): When true, adds additional execution information to the returned status-map, aiding in instruction analysis.
  • :error-data-string (boolean): When true, the :data key in serialized ExceptionInfo (via commando.impl.utils/serialize-exception) will be a string representation of the data. When false, it will return the original map structure.
  • :hook-execute-start (fn [status-map]): if not nil, can run procedure passed in value.
  • :hook-execute-end (fn [status-map]): if not nil, can run procedure passed in value.

Example (binding [commando.impl.utils/execute-config {:debug-result true :error-data-string false :hook-execute-start (fn [e] (println (:uuid e))) :hook-execute-end (fn [e] (println (:uuid e) (:stats e)))}] (commando.core/execute [commando.commands.builtin/command-from-spec] {"1" 1 "2" {:commando/from ["1"]} "3" {:commando/from ["2"]}}))

Dynamic configuration for `commando/execute` behavior.
- `:debug-result` (boolean): When true, adds additional execution
   information to the returned status-map, aiding in instruction analysis.
- `:error-data-string` (boolean): When true, the `:data` key in
   serialized `ExceptionInfo` (via `commando.impl.utils/serialize-exception`)
   will be a string representation of the data. When false, it will return
   the original map structure.
- `:hook-execute-start` (fn [status-map]): if not nil, can run procedure
   passed in value.
- `:hook-execute-end` (fn [status-map]): if not nil, can run procedure
   passed in value.

Example
  (binding [commando.impl.utils/*execute-config*
            {:debug-result true
             :error-data-string false
             :hook-execute-start (fn [e] (println (:uuid e)))
             :hook-execute-end (fn [e] (println (:uuid e) (:stats e)))}]
     (commando.core/execute
       [commando.commands.builtin/command-from-spec]
       {"1" 1
        "2" {:commando/from ["1"]}
        "3" {:commando/from ["2"]}}))
sourceraw docstring

*execute-internals*clj/s

Dynamic variable to keep context information about the execution setup.

  • :uuid the unique name of execution, generated everytime the user invoke commando.core/execute
  • :stack in case of user use commando.commands.builtin/command-macro-spec, or commando.commands.query-dsl/command-resolve-spec or any sort of commands what invoking commando.core/execute inside of parent instruction by simulation recursive call, the :stack key will store the invocation stack in vector of :uuids
Dynamic variable to keep context information about the execution
setup.
- `:uuid` the unique name of execution, generated everytime the user
  invoke `commando.core/execute`
- `:stack` in case of user use `commando.commands.builtin/command-macro-spec`,
  or `commando.commands.query-dsl/command-resolve-spec` or any sort of
  commands what invoking `commando.core/execute` inside of parent instruction
  by simulation recursive call, the :stack key will store the invocation stack
  in vector of :uuids
sourceraw docstring

-execute-internals-pushclj/s

(-execute-internals-push uuid-execute-identifier)

Update execute-internals structure

Update *execute-internals* structure
sourceraw docstring

command-map-spec-registryclj/s

(command-map-spec-registry)

Return :registry value in dynamic scoupe. Required to run commando.core/execute inside of parent execute invocation.

See commando.core/execute commando.core/execute-commands!(binding)

Return `:registry` value in dynamic scoupe.
Required to run `commando.core/execute` inside
of parent execute invocation.

See
  `commando.core/execute`
  `commando.core/execute-commands!`(binding)
sourceraw docstring

exception-message-headerclj/s

source

execute-configclj/s

(execute-config)

Returns the effective configuration for commando/execute, getting data from dynamic variable commando.impl.utils/*execute-config*

Returns the effective configuration for `commando/execute`, getting data from dynamic variable `commando.impl.utils/*execute-config*`
sourceraw docstring

format-timeclj/s

(format-time t)

Formats a time t in nanoseconds to a string with units (ns, µs, ms, or s).

Formats a time `t` in nanoseconds to a string with units (ns, µs, ms, or s).
sourceraw docstring

hook-processclj/s

(hook-process status-map hook)

Function will handle a hooks passed from users. Available hooks:

  • :hook-execute-start,
  • :hook-execute-end.

Read more: commando.impl.utils/*execute-config*

Function will handle a hooks passed from users.
Available hooks:
 - `:hook-execute-start`,
 - `:hook-execute-end`.

Read more:
   `commando.impl.utils/*execute-config*`
sourceraw docstring

malli:driver-specclj/s

source

malli:driver-step-specclj/s

Defines a single step in a driver pipeline or a standalone driver invocation.

Defines a single step in a driver pipeline or a standalone driver invocation.
sourceraw docstring

nowclj/s

(now)

Returns a high-resolution timestamp in nanoseconds.

Returns a high-resolution timestamp in nanoseconds.
sourceraw docstring

(print-stats status-map)
(print-stats status-map title)

Prints a formatted summary of the execution stats from a status-map.

Example (print-stats (commando.core/execute [commando.commands.builtin/command-from-spec] {"1" 1 "2" {:commando/from ["1"]} "3" {:commando/from ["2"]}})) OUT=> Execution Stats: 1 execute-commands! 281.453µs = execute 1.926956ms

(print-stats (binding [commando.impl.utils/execute-config {:debug-result true}] (commando.core/execute [commando.commands.builtin/command-from-spec] {"1" 1 "2" {:commando/from ["1"]} "3" {:commando/from ["2"]}}))) OUT=> Execution Stats: 1 use-registry 141.373µs 2 find-commands 719.128µs 3 build-deps-tree 141.061µs 4 sort-commands-by-deps 112.841µs 5 execute-commands! 78.601µs = execute 1.466249ms

See More commando.impl.utils/*execute-config*

Prints a formatted summary of the execution stats from a status-map.

Example
  (print-stats
    (commando.core/execute
      [commando.commands.builtin/command-from-spec]
      {"1" 1
       "2" {:commando/from ["1"]}
       "3" {:commando/from ["2"]}}))
  OUT=>
   Execution Stats:
     1  execute-commands! 281.453µs
     =  execute           1.926956ms

  (print-stats
    (binding [commando.impl.utils/*execute-config*
              {:debug-result true}]
      (commando.core/execute
        [commando.commands.builtin/command-from-spec]
        {"1" 1
         "2" {:commando/from ["1"]}
         "3" {:commando/from ["2"]}})))
  OUT=>
   Execution Stats:
     1  use-registry          141.373µs
     2  find-commands         719.128µs
     3  build-deps-tree       141.061µs
     4  sort-commands-by-deps 112.841µs
     5  execute-commands!     78.601µs
     =  execute               1.466249ms


See More
 `commando.impl.utils/*execute-config*`
sourceraw docstring

(print-trace execution-fn)

Wraps an execution function and prints a flamegraph of all nested commando/execute calls with timing stats, instruction keys, and optional titles.

Add :__title or "__title" to the top level of any instruction to annotate that node in the flamegraph output.

Takes a zero-argument function that calls commando/execute and returns its result unchanged.

Example (defmethod commando.commands.builtin/command-mutation :rand-n [_macro-type {:keys [v]}] (:instruction (commando.core/execute [commando.commands.builtin/command-apply-spec] {:commando/apply v := (fn [n] (rand-int n))})))

(defmethod commando.commands.builtin/command-macro :sum-n [_macro-type {:keys [v]}] {:__title "sum random" :commando/fn (fn [& v-coll] (apply + v-coll)) :args [v {:commando/mutation :rand-n :v 200}]})

(print-trace #(commando.core/execute [commando.commands.builtin/command-fn-spec commando.commands.builtin/command-from-spec commando.commands.builtin/command-macro-spec commando.commands.builtin/command-mutation-spec] {:value {:commando/mutation :rand-n :v 200} :result {:commando/macro :sum-n :v {:commando/from [:value]}}}))

OUT=> Printing Flamegraph for executes: ———59f2f084-28f6-44fd-bf52-1e561187a2e5 |keys: :value, :result |execute-commands! 1.123606ms |execute 1.92817ms :———e4e245ca-194a-43c6-9d7e-9225e0424c46 : |execute-commands! 66.344µs : |execute 287.669µs :———77de8840-c9d3-4baa-b0d6-8a9806ede29d : |title: sum random : |keys: :__title, :commando/fn, :args : |execute-commands! 372.566µs : |execute 721.636µs : :———0aefeb8e-04b2-4e77-b526-6969c08f9bb5 : : |execute-commands! 39.221µs : : |execute 264.591µs

Wraps an execution function and prints a flamegraph of all nested
`commando/execute` calls with timing stats, instruction keys, and
optional titles.

Add `:__title` or `"__title"` to the top level of any instruction
to annotate that node in the flamegraph output.

Takes a zero-argument function that calls `commando/execute` and
returns its result unchanged.

Example
  (defmethod commando.commands.builtin/command-mutation :rand-n
    [_macro-type {:keys [v]}]
    (:instruction
     (commando.core/execute
       [commando.commands.builtin/command-apply-spec]
       {:commando/apply v
        := (fn [n] (rand-int n))})))

  (defmethod commando.commands.builtin/command-macro :sum-n
    [_macro-type {:keys [v]}]
    {:__title "sum random"
     :commando/fn (fn [& v-coll] (apply + v-coll))
     :args [v
            {:commando/mutation :rand-n
             :v 200}]})

  (print-trace
    #(commando.core/execute
       [commando.commands.builtin/command-fn-spec
        commando.commands.builtin/command-from-spec
        commando.commands.builtin/command-macro-spec
        commando.commands.builtin/command-mutation-spec]
       {:value {:commando/mutation :rand-n :v 200}
        :result {:commando/macro :sum-n
                 :v {:commando/from [:value]}}}))

  OUT=>
    Printing Flamegraph for executes:
    ———59f2f084-28f6-44fd-bf52-1e561187a2e5
       |keys: :value, :result
       |execute-commands! 1.123606ms
       |execute           1.92817ms
       :———e4e245ca-194a-43c6-9d7e-9225e0424c46
       :   |execute-commands! 66.344µs
       :   |execute           287.669µs
       :———77de8840-c9d3-4baa-b0d6-8a9806ede29d
       :   |title: sum random
       :   |keys: :__title, :commando/fn, :args
       :   |execute-commands! 372.566µs
       :   |execute           721.636µs
       :   :———0aefeb8e-04b2-4e77-b526-6969c08f9bb5
       :   :   |execute-commands! 39.221µs
       :   :   |execute           264.591µs
sourceraw docstring

resolvable-fn?clj/s

(resolvable-fn? x)
source

ResolvableFnclj/s

source

resolve-fnclj/s

(resolve-fn x)

Normalize x to a function (fn? x) => true.

  • Fn((fn [] ..),:keyword)
  • Vars(#'clojure.core/str, #'str),
  • Symbols('clojure.core/str, 'str)

:clj supports fn?/Var/Symbol (with requiring-resolve fallback). :cljs only accepts actual functions

Normalize `x` to a function (fn? x) => true.

 - Fn((fn [] ..),:keyword)
 - Vars(#'clojure.core/str, #'str),
 - Symbols('clojure.core/str, 'str)

:clj  supports fn?/Var/Symbol (with requiring-resolve fallback).
:cljs only accepts actual functions
sourceraw docstring

serialize-exceptionclj/s

(serialize-exception e)

Serializes errors into data structures.

Serializes errors into data structures.
sourceraw docstring

serialize-exception-fnclj/s≠multimethod

clj

Multimethod for serializing exceptions to maps. Dispatch based on exception class To add custom serialization for your exception type:

Example (defmethod serialize-exception-fn ClassOfException [e] {:type "my-exception" :message (.getMessage e) ...})

See commando.impl.utils/serialize-exception

Multimethod for serializing exceptions to maps.
Dispatch based on exception class
To add custom serialization for your exception type:

Example
  (defmethod serialize-exception-fn ClassOfException [e]
    {:type "my-exception"
     :message (.getMessage e)
     ...})

See
   `commando.impl.utils/serialize-exception`
cljs

Multimethod for serializing exceptions to maps. dispatch differentiate two type of exception. Not supposed to be extended in cljs

See commando.impl.utils/serialize-exception

Multimethod for serializing exceptions to maps.
dispatch differentiate two type of exception. Not supposed
to be extended in cljs

See
   `commando.impl.utils/serialize-exception`
source (clj)source (cljs)raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close