-
Notifications
You must be signed in to change notification settings - Fork 5
Potential to integrate Vaxine as CRDT backend. #113
Comments
Hello @thruflo, how are you? Thanks for sharing your thoughts. In general, and in my personal understanding, stateful entities should have a live GenServer instance per PersistenceId, that is, whenever the client sends a request that has a persistence id X, this request will always be handled by the equivalent GenServer X instance. That way we were able to spread these instances across the cluster and still keep a healthy reference to them when we need to reference them. defmodule EventSourcedEntityActor do
use GenServer
def init(%{persistor: persistor, persistence_id: x} = initial_state) do
Process.flag(:trap_exit, true)
.....
{:ok, initial_state}
end
def handle_call({:persist_event, event}, from, %{persistor: persistor, persistence_id: id} = state)
persistor.save(id, event)
....
end
def handle_call(:snapshot, from, %{persistor: persistor, persistence_id: id} = state)
persistor.snapshot(id, state)
....
end
def terminate(_reason, %{persistor: persistor, persistence_id: id} = state)
persistor.snapshot(id, state)
end
....
end So basically we need to start by defining the Behavior or Protocol contract. After that, another question would be how to manage these dependencies in the Proxy, that is, we are going to add directly to the proxy dependencies all possible implementations that we have, and this leads to an increasingly larger Proxy with more dependencies and possibly consuming more resources, Or is there any alternative to this scenario? I don't know in Elixir or Erlang any plugin pattern, or library, that is viable for our scenario, but I'm researching it. Anyway, I tried to give you some context, any new ideas would be welcome as we are still in the design phase of this item. |
Thanks, bear with me and I'll have a chat with the team our end. On the proxy dependencies point, yes, my first thought would be a strategy pattern (where you can configure the persistence option much like you configure the email sending library for Phoenix) but I think it depends on how you're packaging and deploying. |
Yes, the idea is that the adapter itself is located via the runtime configuration, so when the proxy is deployed we take the adapter implementation via the configuration and when we start GenServer we pass it on |
Hi,
Just raising the suggestion following a discord discussion with @sleipnir. Vaxine (https://vaxine.io) is a project developing a rich-CRDT database, building on https://antidotedb.eu, with the core database in Erlang and the higher levels in Elixir.
Hopefully Vaxine could be one of the pluggable storage options underpinning the Eigr proxy CRDT entity types. Happy to feed in on interface design and put some time into a working demo integration if useful. On which, it would be useful to understand:
Thanks,
James.
The text was updated successfully, but these errors were encountered: