Sha256: 3bff9e12db1ca7e2e39e27ce6ba67e794e052e967923a38e836d6bf87f66c425
Contents?: true
Size: 839 Bytes
Versions: 26
Compression:
Stored size: 839 Bytes
Contents
module Euston module EventStore module Dispatcher class AsynchronousDispatcher def initialize(bus, persistence, &block) @bus = bus @persistence = persistence @handle_exception = block_given? ? block : Proc.new {} start end def dispatch(commit) Thread.fork(commit) { |c| begin_dispatch c } end protected def begin_dispatch(commit) begin @bus.publish commit @persistence.mark_commit_as_dispatched commit rescue Exception => e @handle_exception.call commit, e end end private def start @persistence.init @persistence.get_undispatched_commits.each { |commit| dispatch commit } end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems