This file contains hidden or 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
| RED="\[\033[0;31m\]" | |
| YELLOW="\[\033[0;33m\]" | |
| GREEN="\[\033[0;32m\]" | |
| BLUE="\[\033[0;34m\]" | |
| LIGHT_RED="\[\033[1;31m\]" | |
| LIGHT_GREEN="\[\033[1;32m\]" | |
| WHITE="\[\033[1;37m\]" | |
| LIGHT_GRAY="\[\033[0;37m\]" | |
| COLOR_NONE="\[\e[0m\]" | |
This file contains hidden or 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
| RED="\[\033[0;31m\]" | |
| YELLOW="\[\033[0;33m\]" | |
| GREEN="\[\033[0;32m\]" | |
| BLUE="\[\033[0;34m\]" | |
| LIGHT_RED="\[\033[1;31m\]" | |
| LIGHT_GREEN="\[\033[1;32m\]" | |
| WHITE="\[\033[1;37m\]" | |
| LIGHT_GRAY="\[\033[0;37m\]" | |
| COLOR_NONE="\[\e[0m\]" |
This file contains hidden or 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 "event_sourcing/command" | |
| require "aggregates/mathtrade" | |
| module Commands | |
| RequestMathtrade = EventSourcing::Command.new(:mathtrade_id, :wantlist) do |event_store| | |
| stream = event_store.get_stream(mathtrade_id) | |
| mathtrade = Aggregates::Mathtrade.new(stream.events) | |
| event_store.append(mathtrade_id, stream.version, mathtrade.request(wantlist: wantlist)) | |
| end | |
| end |
This file contains hidden or 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
| module EventSourcing | |
| class AggregateManager | |
| include Celluloid | |
| def instance_of(klass, id) | |
| # So, in order to remove it when terminated, now I use supervise_as(), | |
| # But I have to remove the exlusive mode because it can't be used with | |
| # the blocks that supervise_as() uses under the hood. | |
| # But now I don't think access to this method is serialized as it was | |
| # with __exclusive__ |
This file contains hidden or 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 |
This file contains hidden or 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 on_message(message) | |
| when Aggregate::Message | |
| instance_of(message.aggregate, message.id).message(message.message, envelope.ivar) | |
| Behaviour::MESSAGE_PROCESSED | |
| end | |
| end |
This file contains hidden or 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/actor" | |
| class SampleApp < Concurrent::Actor::Context | |
| private_class_method :spawn, :spawn! | |
| def self.run! | |
| spawn!(:sample_app) | |
| end |
This file contains hidden or 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 "unit_helper" | |
| require "event_sourcing/event/bus/stream" | |
| describe EventSourcing::Event::Bus::Stream do | |
| let(:bus_stream) { EventSourcing::Event::Bus::Stream.new(store_stream, event_bus) } | |
| let(:store_stream) { instance_double("EventSourcing::Event::Store::Stream") } | |
| let(:event_bus) { instance_double("EventSourcing::Event::Bus::Reference") } | |
| context "each" do | |
| before do |
This file contains hidden or 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
| D, [2014-08-05T01:43:41.353000 #27891] DEBUG -- /: received [:spawn, {:name=>:sample_app, :args=>[#<EventSourcing::Event::Store::Memory:0x5d459764 @events_with_stream_id=[]>], :class=>EventSourcing::Application::Actor, :initialized=>#<Concurrent::IVar:0x6cacfb5c @freeze_on_deref=nil, @event=#<Concurrent::Event:0x738a501f @mutex=#<Mutex:0x7d925e7b>, @condition=#<Concurrent::Condition:0x14791da5 @condition=#<ConditionVariable:0x1b894623>>, @set=false>, @mutex=#<Mutex:0x515bb1f4>, @dup_on_deref=nil, @copy_on_deref=nil, @observers=#<Concurrent::CopyOnWriteObserverSet:0x5b0033e6 @mutex=#<Mutex:0x6a4f6fb6>, @observers={}>, @state=:pending, @do_nothing_on_deref=true>}, nil] from #<Thread:0x52f4c41> | |
| D, [2014-08-05T01:43:41.352000 #27891] DEBUG -- /default_dead_letter_handler: received :supervise from #<Concurrent::Actor::Reference / (Concurrent::Actor::Root)> | |
| D, [2014-08-05T01:43:41.364000 #27891] DEBUG -- /sample_app/event_bus/event_publisher/SampleApp::Logger: received :supervise from #<EventSourcing::Event::Publis |
This file contains hidden or 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
| defp apply_events(events) do | |
| Enum.reduce(events, %{}, fn(event, state) -> | |
| apply_event(event.name, event.data, state) | |
| end) | |
| end |
OlderNewer