You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-45Lines changed: 46 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,24 +5,27 @@
5
5
6
6
A lightweight/efficient cron-like job scheduling library for Erlang.
7
7
8
-
Ecron does not poll the system on a minute-by-minute basis like cron does.
9
-
All jobs is assigned to a single process, just run as same as the [timer](http://erlang.org/doc/man/timer.html).
8
+
All Ecron's jobs is assigned to one single gen_server process, just run as same as the [stdlib's timer](http://erlang.org/doc/man/timer.html).
10
9
11
-
It organize the tasks to be run in a ordered_set ets with the next time to run as key.
10
+
It organize the jobs to be run in a ordered_set ets with the next time to run as key.
12
11
This way, you only need one process that calculates the time to wait until the next task should be executed,
13
-
then spawn the process to execute that task. Saves lots of processes.
12
+
then spawn the process to execute that task.
14
13
more detail see [Implementation](#Implementation).
15
14
16
-
This implementation also prevents a lot of messages from flying around.
15
+
Ecron does not poll the system on a second-by-second basis like cron does.
16
+
The advantage of not doing this is to avoid lots of messages flying around.
17
+
18
+
All jobs are managed in one process, rather than running one job per process,
19
+
which saves lots of processes and avoids taking up a lot of memory.
20
+
After all, most of the time the process is waiting(do nothing but eat memory).
17
21
18
22
It offers:
19
23
20
24
* Both cron-like scheduling and interval-based scheduling.
21
-
* Well tested by `PropTest`.
22
-
* Use gen_server timeout(`receive after`) at any given time (rather than reevaluating upcoming jobs every second/minute).
23
-
* Minimal overhead. ecron aims to keep its code base small.
25
+
* Well tested by [PropTest](https://github.com/proper-testing/proper).
26
+
* Using gen_server timeout(`receive after`) at any given time (rather than reevaluating upcoming jobs every second/minute).
24
27
25
-
You can find a collection of general best practices in [Full Erlang Examples](https://github.com/zhongwencool/ecron/blob/master/examples/titan_erlang) and [Full Elixir Examples](https://github.com/zhongwencool/ecron/blob/master/examples/titan_elixir).
28
+
You can find a collection of general practices in [Full Erlang Examples](https://github.com/zhongwencool/ecron/blob/master/examples/titan_erlang) and [Full Elixir Examples](https://github.com/zhongwencool/ecron/blob/master/examples/titan_elixir).
26
29
27
30
## Installation
28
31
@@ -66,24 +69,25 @@ You can find a collection of general best practices in [Full Erlang Examples](ht
You can also reload task manually by `ecron:reload().`
82
-
* Global jobs depend on [global](http://erlang.org/doc/man/global.html), only allowed to be added statically, [check for more detail](https://github.com/zhongwencool/ecron/blob/master/doc/global.md).
Additionally, `ecron` alsocollectjob's latest 16 results and execute times, you can observe by `ecron:statistic(Name)`.
174
+
175
+
[Check this for global_jobs workflow](https://github.com/zhongwencool/ecron/blob/master/doc/global.md#Implementation).
176
+
177
+
## Telemetry
178
+
Ecron publish events through telemetry, you can handle those events by [this guide](https://github.com/zhongwencool/ecron/blob/master/doc/telemetry.md),
179
+
such as you can monitor events dispatch duration and failures to create alerts which notify somebody.
2. Nothing will happen if the `global_jobs` is empty.
56
+
3. When `global_jobs` is not empty, `ecron_sup` would start_link `ecron_monitor` worker (gen_server).
57
+
4.`ecron_monitor` subscribes node's up/down messages by [net_kernel:monitor_nodes(true)](http://erlang.org/doc/man/net_kernel.html#monitor_nodes-1), when it initializes.
58
+
5. Checking if there is enough `ecron` process in the cluster(`global_quorum_size`).
59
+
6. Trying to terminate global job manager process when cluster's `ecron` number less than `global_quorum_size`.
60
+
7. Otherwise, trying to start a global job manager process, This gen_server register by [global:register_name/2](http://erlang.org/doc/man/global.html#register_name-2).
61
+
8. All the nodes are rushing to register this global jobs manager process, only one node will success, other node's `ecron_monitor` would link this process if the process already exists.
62
+
9. The `ecron_monitor` will receive notification, when node down/up or the global job manager dies.
0 commit comments