Skip to content

Khepri 0.11.0

Compare
Choose a tag to compare
@dumbbell dumbbell released this 30 Jan 08:50
· 166 commits to main since this release
v0.11.0
e85821b

At this point, Khepri should be considered Beta and not production ready. The API will likely evolve and future releases will likely introduce breaking changes. The goal of this release is to make it easy for anyone to try it and possibly give feedback.

What's new in Khepri 0.11.0

Return {ok, _} | {error, _} from functions returning cluster members

Breaking change

Always returning a list, hiding any error behind an empty list, proved to be a bad design, as it made it way too easy to ignore or miss errors and act upon them.

This kind of return value was also inconsistent with the rest of the API.

The members list is now wrapped into an {ok, Members} tuple. Likewise for nodes lists. This forces the caller to be aware of errors and handle them. The afftected APIs are:

  • khepri_cluster:members/{1,2}
  • khepri_cluster:locally_known_members/{1,2}
  • khepri_cluster:nodes/{1,2}
  • khepri_cluster:locally_known_nodes/{1,2}

Here is an example of the change to make to your code:

  • Up-to Khepri 0.10.x:

    lists:foreach(
        fun(Node) ->
            do_something_with_node(Node)
        end,
        khepri_cluster:nodes(StoreId)).
  • Starting from Khepri 0.11.0:

    case khepri_cluster:nodes(StoreId) of
        {ok, Nodes} ->
            lists:foreach(
                fun(Node) ->
                    do_something_with_node(Node)
                end,
                Nodes);
        {error, _Reason} = Error ->
            handle_error(Error)
    end.

While working on this:

  • khepri_cluster:members/0, khepri_cluster:locally_known_members/0, khepri_cluster:nodes/0 and khepri_cluster:locally_known_nodes/0 were added to work on the default store. This is inline with all other API functions.
  • Type specifications and documentation was added for all these functions, existing and new.

See #244.

Speed up members/nodes local query

Ra now provides a new ra_leaderboard:lookup_members/1 function to query members locally that is faster that a call to the local Ra server. Khepri started to use it and, if it returns an error, it will fall back to the previous Ra server query.

See #240.

Other changes

  • Use monotonic times to mesaure a duration, not system time (#245).
  • Do not enforce the favor option when querying the "keep while" conditions or the projections states (#246).
  • Ra was bumped from 2.7.0 to 2.7.3 (#241).

Download

Khepri 0.11.0 is available from Hex.pm: https://hex.pm/packages/khepri/0.11.0

Upgrade

Using Rebar:

  1. Update your rebar.config:

    %% In rebar.config
    {deps, [{khepri, "0.11.0"}]}.
  2. Run rebar3 upgrade khepri.

Using Erlang.mk:

  1. Update your Makefile:

    %% In your Makefile
    dep_khepri = hex 0.11.0
  2. Remove the deps/khepri directory. The new version will be fetched the next time you build your project.

Documentation

The documentation for Khepri 0.11.0 is available on Hex.pm.