derekkraan / delta_crdt_ex

Use DeltaCrdt to build distributed applications in Elixir
MIT License
493 stars 36 forks source link

Feature: allow reading only given keys #55

Closed sascha-wolf closed 3 years ago

sascha-wolf commented 3 years ago

Resolves #54


This PR implements the proposal from this comment where calling:

DeltaCrdt.read(crdt, ["my-key"])
# => %{"my-key" => ...}

leads to a call to the used crdt module like this:

crdt_module.read(state, ["my-key"])

That is, the given keys are 1to1 forwarded to the crdt_module as a second argument.

This allows to make use of the read/2 function on AWLWWMap which makes it possible to only fetch the given keys from the map instead of fetching everything all the time.

For the user's benefit a small example was added to the README.

sascha-wolf commented 3 years ago

@derekkraan I'd be grateful if you could take a look at this. 🙂

derekkraan commented 3 years ago

Sorry for taking so long to look at this @sascha-wolf

It's merged now and I'll release a new version today.