Last active
August 29, 2015 14:03
-
-
Save Papipo/0f6f8d47c6a0cecdd2a8 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
require "concurrent/actress" | |
module EventSourcing | |
class AggregateManager | |
include Concurrent::Actress::Context | |
def initialize | |
@registry = {} | |
end | |
def on_message(message) | |
instance_of(message[1], message[2]).message(message) | |
end | |
private | |
def instance_of(klass, id) | |
unless @registry[id] && !@registry[id].terminated? | |
@registry[id] = klass.spawn!(id) | |
end | |
@registry[id] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment