std.scheduler.spawn

*defaults*

dynamic

*delay*

dynamic

*group*

dynamic

*interval*

dynamic

*job*

dynamic

*spawn*

dynamic

*spawn-id*

dynamic

*timing*

dynamic

add-job

added in 3.0

(add-job spawn job-id job)

adds job to the spawn

clear

added in 3.0

(clear runtime program-id)

clears the program and past spawn information

count-jobs

added in 3.0

(count-jobs spawn)

returns the number of jobs

count-spawn

added in 3.0

(count-spawn runtime program-id)

counts all running spawns

create-handler

added in 3.0

(create-handler {:keys [type], :as program} spawn)

creates a run handler

(create-handler (assoc defaults :type :basic) (create-spawn)) => fn?

create-handler-basic

added in 3.0

(create-handler-basic program spawn)

creates a basic handler

create-handler-constant

added in 3.0

(create-handler-constant {:keys [args-fn], :as program} spawn)

creates a constant handler

create-spawn

added in 3.0

(create-spawn)(create-spawn {:keys [create-fn continue-fn interval global full state], :as program} spawn-id)

creates a new spawn

(-> (create-spawn (merge defaults {:interval 1}) “spawn.1”) (spawn-info)) => {:id “spawn.1”, :status :created, :duration “0ms”, :jobs {:submitted 0 :succeeded 0 :errored 0 :waiting 0}, :state nil}

earliest-spawn

added in 3.0

(earliest-spawn runtime program-id)

returns earliest created spawn

get-all-spawn

added in 3.0

(get-all-spawn runtime program-id)

returns all running spawns

get-job

added in 3.0

(get-job spawn job-id)(get-job spawn job-id ks)

retrieves a job given key

(-> (doto (create-spawn) (add-job “j.1” {:id “j.1”}))

(get-job "j.1"))

=> {:id “j.1”}

get-program

added in 3.0

(get-program runtime program-id)

gets the program given runtime and program-id

(get-program |rt3| :test-program) => {}

get-props

added in 3.0

(get-props spawn)(get-props spawn k)

gets the spawn prop given key

(-> (create-spawn) (get-props :submitted)) => 0

get-spawn

added in 3.0

(get-spawn runtime program-id spawn-id)

gets running spawn with id

get-state

added in 3.0

(get-state runtime program-id)

gets the global state for the program-id

(get-state |rt3| :test-program) => {}

handler-run

added in 3.0

(handler-run {:keys [args-fn main-fn merge-fn success-fn error-fn]} {:keys [state], :as spawn} {:keys [time return], job-id :id, :as job})

handles the

(let ret (h/incomplete) job {:id “j.0” :time 0 :return ret} spawn (doto (create-spawn) (add-job “j.0” job)) result {:task (handler-run defaults spawn job)} (assoc result :return @ret :meta @(:output spawn))) => (contains-in {:task “j.0” 0 :return nil :meta {:status :success, :data nil, :exception nil, :time 0, :start integer? :end integer?}})

kill-all

added in 3.0

(kill-all runtime program-id)

kills all the running tasks

(-> (doto |rt3| (kill-all :test-program)) (count-spawn :test-program)) => 0

kill-spawn

added in 3.0

(kill-spawn runtime program-id spawn-id)

stops a spawn and all jobs

(kill-spawn |rt3| :test-program “s1”) => spawn?

latest

added in 3.0

(latest runtime program-id)

returns the latest active or past spawn

latest-spawn

added in 3.0

(latest-spawn runtime program-id)

returns latest created spawn

latest-stopped

added in 3.0

(latest-stopped runtime program-id)

returns the most recently stopped spawn

list-job-ids

added in 3.0

(list-job-ids spawn)

lists all job ids

list-jobs

added in 3.0

(list-jobs spawn)

list all jobs

list-spawn

added in 3.0

(list-spawn runner program-id)(list-spawn runtime program-id order)

lists all running spawns

list-stopped

added in 3.0

(list-stopped runtime program-id)

lists all stopped spawns

remove-job

added in 3.0

(remove-job spawn job-id)

removes a job given key

run

added in 3.0

(run runtime program-id)(run runtime program-id opts spawn-id)

constructs and starts a spawn loop

schedule-timing

added in 3.0

(schedule-timing type props last)(schedule-timing type props last now)

calculates the timing for the next schedule

(schedule-timing :constant {:interval 1000} 500 635) => 1500 865

send-result

added in 3.0

(send-result {:keys [output], :as spawn} result)

sends the result to spawn output

set-props

added in 3.0

(set-props spawn k v & more)

updates the spawn props

(-> (create-spawn) (set-props :submitted inc :errored 4 :started true) (select-keys :submitted :errored :started)) => {:submitted 1, :errored 4, :started true}

spawn-info

added in 3.0

(spawn-info {:keys [id board props output state exit], :as spawn})

returns the spawn info

spawn-loop

added in 3.0

(spawn-loop runtime {:keys [time-fn continue-fn], :as program} {:keys [props exit board], :as spawn})

creates a spawn loop

spawn-save-past

added in 3.0

(spawn-save-past runtime program-id {spawn-id :id, :as spawn})

helper function to move spawn from :running to :past

spawn-status

added in 3.0

(spawn-status {:keys [props exit], :as spawn})

returns the spawn status

spawn?

added in 3.0

(spawn? obj)

checks that object is a spawn

stop-all

added in 3.0

(stop-all runtime program-id)

stops all the running tasks

(-> (doto |rt3| (stop-all :test-program)) (count-spawn :test-program)) => 0

stop-spawn

added in 3.0

(stop-spawn runtime program-id spawn-id)

stop a spawn and waits for jobs to finish

update-job

added in 3.0

(update-job spawn job-id f & args)

updates a job given key

wrap-schedule

added in 3.0

(wrap-schedule {:keys [type], :as program} {:keys [props], :as spawn} schedule-fn)

wrapper for the schedule function