Public Vars

Back

restart-agent (clj)

(source)

function

(restart-agent a new-state & options)
When an agent is failed, changes the agent state to new-state and then un-fails the agent so that sends are allowed again. If a :clear-actions true option is given, any actions queued on the agent that were being held while it was failed will be discarded, otherwise those held actions will proceed. The new-state must pass the validator if any, or restart will throw an exception and the agent will remain failed with its old state and error. Watchers, if any, will NOT be notified of the new state. Throws an exception if the agent is not failed.

Examples

typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

#?@(:cljs [] :default [
cc/agent-error [t/AnyAgent :-> (t/Nilable Throwable)]
cc/restart-agent (t/All [x] [(t/Agent x) x & :optional {:clear-actions t/Any} :-> t/Any])
cc/set-error-handler! (t/All [x] [(t/Agent x) [(t/Agent x) Throwable :-> t/Any] :-> t/Any])
cc/error-handler (t/All [[a :< t/AnyAgent]] [a :-> (t/Nilable [a Throwable :-> t/Any])])
cc/set-error-mode! [t/AnyAgent (t/U ':fail ':continue) :-> t/Any]
cc/error-mode [t/AnyAgent :-> t/Any]
cc/agent-errors [t/AnyAgent :-> (t/Nilable (t/ASeq Throwable))]
cc/clear-agent-errors [t/AnyAgent :-> t/Any]
cc/shutdown-agents [:-> t/Any]
])