-
-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathadapter.ex
64 lines (51 loc) · 1.73 KB
/
adapter.ex
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
defmodule Quantum.Storage.Adapter do
@moduledoc """
Bahaviour to be implemented by all Storage Adapters.
**WARNING: This Adapter is experimental and will therefore not adhere to semantic versioning.
It could undergo massive changes even in patch releases.**
"""
alias Quantum.Job
@typedoc """
The calling scheduler Module
"""
@type scheduler_module :: atom
@typedoc """
The expected return is `:ok`, every other result will terminate the scheduler.
"""
@type ok :: :ok
@doc """
Load saved jobs from storage
Returns `:not_applicable` if the storage has never received an `add_job` call or after it has been purged.
In this case the jobs from the configuration weill be loaded.
"""
@callback jobs(scheduler_module) :: :not_applicable | [Job.t()]
@doc """
Save new job in storage.
"""
@callback add_job(scheduler_module, job :: Job.t()) :: ok
@doc """
Delete new job in storage.
"""
@callback delete_job(scheduler_module, job :: Job.name()) :: ok
@doc """
Change Job State from given job.
"""
@callback update_job_state(scheduler_module, job :: Job.name(), state :: Job.state()) :: ok
@doc """
Load last execution time from storage
Returns `:unknown` if the storage does not know the last execution time.
In this case all jobs will be run at the next applicable date.
"""
@callback last_execution_date(scheduler_module) :: :unknown | NaiveDateTime.t()
@doc """
Update last execution time to given date.
"""
@callback update_last_execution_date(
scheduler_module,
last_execution_date :: NaiveDateTime.t()
) :: ok
@doc """
Purge all date from storage and go back to initial state.
"""
@callback purge(scheduler_module) :: ok
end