-
Notifications
You must be signed in to change notification settings - Fork 15
/
scheduler.clj
49 lines (40 loc) · 1.7 KB
/
scheduler.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(ns puppetlabs.trapperkeeper.services.protocols.scheduler)
(defprotocol SchedulerService
(interspaced
[this n f]
[this n f group-id]
"Calls 'f' repeatedly with a delay of 'n' milliseconds between the
completion of a given invocation and the beginning of the following
invocation. Returns an identifier for the scheduled job. An optional
group-id can be provided to collect a set of jobs into one group to allow
them to be stopped together.")
(after
[this n f]
[this n f group-id]
"Calls 'f' once after a delay of 'n' milliseconds.
Returns an identifier for the scheduled job. An optional
group can be provided to associated jobs with each other to allow
them to be stopped together.")
(stop-job [this job]
"Given an identifier of a scheduled job, stop its execution. If an
invocation of the job is currently executing, it will be allowed to
complete, but the job will not be invocated again.
Returns 'true' if the job was successfully stopped, 'false' otherwise.")
(stop-jobs
[this]
[this group-id]
"Stop all the jobs associated with the service. Given an optional group-id
stop only the jobs associated with that group id.
Returns a sequence of maps, each with an identifier for the job and a boolean to
indicate if the job was stopped successfully.")
(count-jobs
[this]
[this group-id]
"Return the number of jobs known to the scheduler service, or the number
of jobs known to the scheduler service by group id. A nil group-id
will return the count of all jobs.")
(get-jobs
[this]
[this group-id]
"Return all the known job identifiers, or the job identifiers associated
with the given group."))