|
1 | 1 | # HLClock |
2 | 2 |
|
3 | | -[](https://travis-ci.org/toniqsystems/hlclock) |
| 3 | +[](https://travis-ci.org/toniqsystems/hlclock) [](https://hex.pm/packages/hlclock) |
4 | 4 |
|
5 | 5 | ## About |
6 | 6 |
|
7 | 7 | Hybrid Logical Clocks (HLC) provide a one-way causality detection using a |
8 | 8 | combination of logical time and physical NTP timestamp. This library adds an |
9 | 9 | additional mechanism for resolving conflicts between timestamps by adding a |
10 | | -unique node id to each HLC. |
| 10 | +unique node id to each HLC timestamp. |
11 | 11 |
|
12 | 12 | These timestamps can be used in place of standard NTP timestamps in order to |
13 | 13 | provide consistent snapshots and causality tracking. HLCs have a fixed space |
14 | 14 | requirement and are bounded close to physical timestamps. |
15 | 15 |
|
16 | 16 | ## Installation |
17 | 17 |
|
18 | | -Now [available in Hex](https://hex.pm/docs/publish), the package can be installed |
19 | | -by adding `hlclock` to your list of dependencies in `mix.exs`: |
| 18 | +First, add `HLClock` to your `mix.exs` dependencies. |
20 | 19 |
|
21 | 20 | ```elixir |
22 | 21 | def deps do |
|
26 | 25 |
|
27 | 26 | ## Usage |
28 | 27 |
|
29 | | -In order to generate HLCs you'll need an HLClock process: |
| 28 | +Starting in version 1.0.0, the `HLClock.Server` is not started as an application |
| 29 | +automatically. `HLClock.start_link/1` is as a short cut to manually start a process: |
30 | 30 |
|
31 | 31 | ```elixir |
32 | 32 | {:ok, clock} = HLClock.start_link() |
33 | 33 | {:ok, ts} = HLClock.send_timestamp(clock) |
34 | 34 | ``` |
35 | 35 |
|
36 | | -You can also supervise clock processes: |
| 36 | +In practice, it is best to have a single `HLClock` running on any given node. |
| 37 | +Toward that end, `HLClock` also provides a `child_spec` that accepts all |
| 38 | +standard `GenServer` opts: |
37 | 39 |
|
38 | 40 | ```elixir |
39 | 41 | children = [ |
40 | 42 | {HLClock, name: :my_hlc_server}, |
41 | 43 | ] |
42 | 44 | ``` |
43 | | - |
44 | | -`HLClock.start_link/1` accepts all arguments for `GenServer`. |
0 commit comments