(add-task scheduler name props)
add a task to the scheduler
(add-task (scheduler {}) :hello {:handler (fn [t params] (println params)) :schedule "* * * * * * *" :params {:data "foo"}})
add a task to the scheduler (add-task (scheduler {}) :hello {:handler (fn [t params] (println params)) :schedule "* * * * * * *" :params {:data "foo"}})
(delete-task scheduler name)
deletes a specific task in the scheduler
(delete-task sch :print-task-2)
deletes a specific task in the scheduler (delete-task sch :print-task-2)
(disable-task scheduler name)
disables a specific task in the scheduler
(disable-task sch :print-task-1)
;; Task is disabled when start!
is called
disables a specific task in the scheduler (disable-task sch :print-task-1) ;; Task is disabled when `start!` is called
(empty-tasks scheduler)
clears all tasks in the scheduler
(empty-tasks sch)
clears all tasks in the scheduler (empty-tasks sch)
(enable-task scheduler name)
enables a specific task in the scheduler
(enable-task sch :print-task-1)
;; Task runs on schedule when start!
is called
enables a specific task in the scheduler (enable-task sch :print-task-1) ;; Task runs on schedule when `start!` is called
(get-instance scheduler name id)
gets an instance of the running task
(get-instance sch :print-task-1 #inst "2016-10-25T11:39:05.000-00:00") ;; retrieves a running instances in the scheduler
gets an instance of the running task (get-instance sch :print-task-1 #inst "2016-10-25T11:39:05.000-00:00") ;; retrieves a running instances in the scheduler
(get-task scheduler name)
gets a specific task in the scheduler
(get-task sch :print-task-1) ;; => #proc{:name :print-task-1, ;; :mode :async, ;; :arglist [:timestamp :params :instance]}
gets a specific task in the scheduler (get-task sch :print-task-1) ;; => #proc{:name :print-task-1, ;; :mode :async, ;; :arglist [:timestamp :params :instance]}
(kill-instance scheduler name id)
kills a single instance of the running task
(kill-instance sch :print-task-1 #inst "2016-10-25T11:39:05.000-00:00") ;; kills a running instances in the scheduler
kills a single instance of the running task (kill-instance sch :print-task-1 #inst "2016-10-25T11:39:05.000-00:00") ;; kills a running instances in the scheduler
(kill-instances scheduler)
(kill-instances scheduler name)
kills all instances of the running task
(kill-instances sch) ;; kills all running instances in the scheduler
(kill-instances sch :print-task-1) ;; kills all running instances for a particular task
kills all instances of the running task (kill-instances sch) ;; kills all running instances in the scheduler (kill-instances sch :print-task-1) ;; kills all running instances for a particular task
(list-instances scheduler)
(list-instances scheduler name)
lists all running instances of a tasks in the scheduler
(list-instances sch) ;; lists all running instances in the scheduler
(list-instances sch :print-task-1) ;; lists all running instances for a particular task
lists all running instances of a tasks in the scheduler (list-instances sch) ;; lists all running instances in the scheduler (list-instances sch :print-task-1) ;; lists all running instances for a particular task
(list-tasks scheduler)
lists all tasks in the scheduler
(list-tasks sch) ;; => [#proc{:name :print-task-1, ;; :mode :async, ;; :arglist [:timestamp :params :instance]} ;; #proc{:name :print-task-2, ;; :mode :async, ;; :arglist [:timestamp :params :instance] }]
lists all tasks in the scheduler (list-tasks sch) ;; => [#proc{:name :print-task-1, ;; :mode :async, ;; :arglist [:timestamp :params :instance]} ;; #proc{:name :print-task-2, ;; :mode :async, ;; :arglist [:timestamp :params :instance] }]
(reparametise-task scheduler name opts)
changes the schedule for an already existing task
(-> (scheduler {:hello {:handler (fn [t params] (println params)) :schedule "* * * * * * *" :params {:data "foo"}}}) (reparametise-task :hello {:data "bar"}))
changes the schedule for an already existing task (-> (scheduler {:hello {:handler (fn [t params] (println params)) :schedule "* * * * * * *" :params {:data "foo"}}}) (reparametise-task :hello {:data "bar"}))
(reschedule-task scheduler name schedule)
changes the schedule for an already existing task
(-> (scheduler {:hello {:handler (fn [t params] (println params)) :schedule "* * * * * * *" :params {:data "foo"}}}) (reschedule-task :hello "/5 * * * * * *"))
changes the schedule for an already existing task (-> (scheduler {:hello {:handler (fn [t params] (println params)) :schedule "* * * * * * *" :params {:data "foo"}}}) (reschedule-task :hello "/5 * * * * * *"))
(restart! scheduler)
restarts the scheduler after a forced shutdown
(restart! sch) ;; All Threads will stop and restart
restarts the scheduler after a forced shutdown (restart! sch) ;; All Threads will stop and restart
(running? scheduler)
checks to see if the scheduler is running
(running? sch) => false
checks to see if the scheduler is running (running? sch) => false
(scheduler handlers)
(scheduler handlers config)
(scheduler handlers config global)
creates a schedular from handlers, or both handlers and config
(def sch (scheduler {:print-task-1 {:handler (fn [t] (prn "Hello 1") (Thread/sleep 2000)) :schedule "/5 * * * * * *"} :print-task-2 {:handler (fn [t] (prn "Hello 2") (Thread/sleep 2000)) :schedule "/2 * * * * * *"}}))
creates a schedular from handlers, or both handlers and config (def sch (scheduler {:print-task-1 {:handler (fn [t] (prn "Hello 1") (Thread/sleep 2000)) :schedule "/5 * * * * * *"} :print-task-2 {:handler (fn [t] (prn "Hello 2") (Thread/sleep 2000)) :schedule "/2 * * * * * *"}}))
(shutdown! scheduler)
forcibly shuts down the scheduler, immediately killing all running threads
(shutdown! sch) ;; All tasks will stop and all running instances killed
forcibly shuts down the scheduler, immediately killing all running threads (shutdown! sch) ;; All tasks will stop and all running instances killed
(simulate scheduler {:keys [start end step pause mode]})
simulates the scheduler running for a certain interval:
(simulate (scheduler {:print-task {:handler (fn [t params instance] (str t params)) :schedule "/2 * * * * * *" :params {:value "hello world"}}}) {:start (java.util.Date. 0) :end (java.util.Date. 100000) :pause 10})
simulates the scheduler running for a certain interval: (simulate (scheduler {:print-task {:handler (fn [t params instance] (str t params)) :schedule "/2 * * * * * *" :params {:value "hello world"}}}) {:start (java.util.Date. 0) :end (java.util.Date. 100000) :pause 10})
(start! scheduler)
starts the scheduler
(start! sch) ;; => {:ticker {:time #inst "2016-10-25T01:20:06.000-00:00", ;; :array [6 20 8 2 25 10 2016]} ;; :clock {:start-time #inst "2016-10-25T01:18:52.184-00:00", ;; :current-time #inst "2016-10-25T01:20:06.001-00:00", ;; :running true}, ;; :cache {}, ;; :registry {:print-task-2 (#inst "2016-10-25T01:20:06.000-00:00"), ;; :print-task-1 (#inst "2016-10-25T01:20:05.000-00:00")}, ;; :array {:handlers [], ;; :ticker {:time #inst "2016-10-25T01:20:06.000-00:00", ;; :array [6 20 8 2 25 10 2016]} ;; :registry {:print-task-2 (#inst "2016-10-25T01:20:06.000-00:00"), ;; :print-task-1 (#inst "2016-10-25T01:20:05.000-00:00")}, ;; :cache {}}}
starts the scheduler (start! sch) ;; => {:ticker {:time #inst "2016-10-25T01:20:06.000-00:00", ;; :array [6 20 8 2 25 10 2016]} ;; :clock {:start-time #inst "2016-10-25T01:18:52.184-00:00", ;; :current-time #inst "2016-10-25T01:20:06.001-00:00", ;; :running true}, ;; :cache {}, ;; :registry {:print-task-2 (#inst "2016-10-25T01:20:06.000-00:00"), ;; :print-task-1 (#inst "2016-10-25T01:20:05.000-00:00")}, ;; :array {:handlers [], ;; :ticker {:time #inst "2016-10-25T01:20:06.000-00:00", ;; :array [6 20 8 2 25 10 2016]} ;; :registry {:print-task-2 (#inst "2016-10-25T01:20:06.000-00:00"), ;; :print-task-1 (#inst "2016-10-25T01:20:05.000-00:00")}, ;; :cache {}}}
(stop! scheduler)
stops the scheduler
(stop! sch) ;; Schedule will stop but running instances will continue to run until completion ;; ;; => {:array {:handlers ;; [{:status :ready, ;; :val {:name :print-task-1, ;; :mode :async, ;; :arglist [:timestamp :params :instance]}} ;; {:status :ready, ;; :val {:name :print-task-2, ;; :mode :async, ;; :arglist [:timestamp :params :instance]}}]}, ;; :registry #reg {}, ;; :cache #cache {}, ;; :clock #clock {:start-time nil, :current-time nil, :running false}, ;; :ticker {:time #inst "2016-10-25T01:22:58.000-00:00", ;; :array [58 22 8 2 25 10 2016]}}
stops the scheduler (stop! sch) ;; Schedule will stop but running instances will continue to run until completion ;; ;; => {:array {:handlers ;; [{:status :ready, ;; :val {:name :print-task-1, ;; :mode :async, ;; :arglist [:timestamp :params :instance]}} ;; {:status :ready, ;; :val {:name :print-task-2, ;; :mode :async, ;; :arglist [:timestamp :params :instance]}}]}, ;; :registry #reg {}, ;; :cache #cache {}, ;; :clock #clock {:start-time nil, :current-time nil, :running false}, ;; :ticker {:time #inst "2016-10-25T01:22:58.000-00:00", ;; :array [58 22 8 2 25 10 2016]}}
(stopped? scheduler)
checks to see if the scheduler is stopped
(stopped? sch) => true
checks to see if the scheduler is stopped (stopped? sch) => true
(trigger! scheduler name)
(trigger! scheduler name key)
manually executes a task, bypassing the scheduler
(trigger! sch :print-task-1)
manually executes a task, bypassing the scheduler (trigger! sch :print-task-1)
(uptime scheduler)
checks to see how long the scheduler has been running
(uptime sch) ;; when the scheduler is stopped, uptime is nil
=> nil
(start! sch)
(uptime sch) ;; uptime is from when the scheduler is started => 7936
checks to see how long the scheduler has been running (uptime sch) ;; when the scheduler is stopped, uptime is `nil` => nil (start! sch) (uptime sch) ;; uptime is from when the scheduler is started => 7936
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close