Liking cljdoc? Tell your friends :D

hara.io.scheduler


*defaults*clj


add-taskclj

(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"}})
raw docstring

delete-taskclj

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

disable-taskclj

(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
raw docstring

empty-tasksclj

(empty-tasks scheduler)

clears all tasks in the scheduler

(empty-tasks sch)

clears all tasks in the scheduler
       
(empty-tasks sch)
raw docstring

enable-taskclj

(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
raw docstring

get-instanceclj

(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
raw docstring

get-taskclj

(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]}
raw docstring

kill-instanceclj

(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
raw docstring

kill-instancesclj

(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
raw docstring

list-instancesclj

(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
raw docstring

list-tasksclj

(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] }]
raw docstring

reparametise-taskclj

(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"}))
raw docstring

reschedule-taskclj

(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 * * * * * *"))
raw docstring

restart!clj

(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
raw docstring

running?clj

(running? scheduler)

checks to see if the scheduler is running

(running? sch) => false

checks to see if the scheduler is running

(running? sch)
=> false
raw docstring

schedulerclj

(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] (Thread/sleep 2000)) :schedule "/5 * * * * * *"} :print-task-2 {:handler (fn [t] (Thread/sleep 2000)) :schedule "/2 * * * * * *"}}))

creates a schedular from handlers, or both handlers and config

(def sch (scheduler
         {:print-task-1
           {:handler (fn [t] (Thread/sleep 2000))
            :schedule "/5 * * * * * *"}
           :print-task-2
           {:handler (fn [t] (Thread/sleep 2000))
            :schedule "/2 * * * * * *"}}))
raw docstring

shutdown!clj

(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
raw docstring

simulateclj

(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})
raw docstring

start!clj

(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 {}}}
raw docstring

stop!clj

(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]}}
raw docstring

stopped?clj

(stopped? scheduler)

checks to see if the scheduler is stopped

(stopped? sch) => true

checks to see if the scheduler is stopped

(stopped? sch)
=> true
raw docstring

trigger!clj

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

uptimeclj

(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
raw docstring

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

× close