Re: [ANN] Khepri 0.1.0 - A tree-like replicated on-disk database library

Frank Muller <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAFA6GnCCHKvCt95mBQ_LN4JN4uczUMh_f78xsHf8=UKA+e7MEw@mail.gmail.com>
Hi Jean-Sebastian

I like it. Don’t you think the provided example (GitHub README.md) should
be like this instead:

%% This transaction checks the left quantity of wood and returns true or

%% false if we need to process a new order.

khepri:transaction(

    fun() ->

        case khepri_tx:get([stock, wood]) of

            {ok, #{[stock, wood] := #{data := Quantity}}}

              when Quantity < 100 ->

                %% There is less than 100 pieces of wood, or there is none

                %% at all (the node does not exist in Khepri). We need to

                %% request a new order.

                {ok, _} = khepri_tx:put([order, wood], ?DATA_PAYLOAD(1000)),

                false;

            _ ->

                 %% There is enough wood left.

                true

        end

    end).

Best
/F.


> Hi!
>
> On behalf of the RabbitMQ team, I'm proud to announce the Khepri
> database library (https://github.com/rabbitmq/khepri)!
>
> Release 0.1.0 is available on;
>      * GitHub (https://github.com/rabbitmq/khepri/releases/tag/v0.1.0)
>      * Hex.pm (https://hex.pm/packages/khepri)
>
> Khepri is a tree-like replicated on-disk database library for Erlang and
> Elixir. This is a library we plan to use inside RabbitMQ as a
> replacement for Mnesia. Indeed, we want to leverage Ra[1], our
> implementation of the Raft consensus algorithm, to have a uniform
> behavior, especially w.r.t. network partitions, across all types of data
> managed by RabbitMQ.
>
> In Khepri, data are organized as nodes in a tree. All tree nodes may
> contain data, not only the leaves. Here is a quick example:
>
>      %% Store "150" under /stock/wood/oak.
>      khepri:insert([stock, wood, oak], 150),
>
>      %% The tree now looks like:
>      %% .
>      %% `-- stock
>      %%     `-- wood
>      %%         `-- oak = 150
>
>      %% Get what is stored under /stock/wood/oak.
>      Ret = khepri:get([stock, wood, oak]),
>      {ok, #{[stock, wood, oak] := #{data := Units}}} = Ret,
>
>      %% Check /stock/wood/oak exists.
>      true = khepri:exists([stock, wood, oak]),
>
>      %% Delete /stock/wood/oak.
>      khepri:delete([stock, wood, oak]).
>
> Most of the concepts and a part of the API are described in the
> documentation (https://rabbitmq.github.io/khepri/). Note that the
> documentation is also far from complete.
>
> The implementation is very alpha at this stage. The internal design
> should not change drastically now but the API and ABI might.
>
> I would love Khepri to be as easy to use and intuitive as possible.
> That's why I'm reaching out to the community! If anyone is interested,
> could you please take a look at the documentation and/or the code and
> share your comments?
>
> Thank you very much!
>
> [1] https://github.com/rabbitmq/ra
>
> --
> Jean-Sébastien Pédron
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.