Last active
September 7, 2018 14:20
-
-
Save deque-blog/5a9ed82fdd62a7cc3b37a9b3de778909 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handle_call({:add, event}, _from, worker) do | |
logEntry = %LogEntry{ | |
origin: worker.name, | |
time: worker.clock, | |
event: event | |
} | |
newWorkerState = %{ worker | | |
clock: worker.clock + 1, | |
eventLog: [logEntry | worker.eventLog] | |
} | |
PubSub.broadcast(@log_replication_topic, {:replication_log, logEntry}) | |
{:reply, :ok, newWorkerState } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment