Sha256: 59b619d3994961d322d91c3943bc3b58e7cad513774fa3a8e8b797f52971e8c8
Contents?: true
Size: 857 Bytes
Versions: 3
Compression:
Stored size: 857 Bytes
Contents
module Aggro # Private: Provides an interface to communicate with an aggregate or saga. # Only loads the target object when needed. class Channel < Struct.new(:id, :type) def forward_command(command) target << command if handles_command?(command) end def handles_command?(command) target_class.allows? command end def handles_query?(query) target_class.responds_to? query end def run_query(query) target.ask query if handles_query? query end private def target @target ||= begin ConcurrentActor.spawn!( name: id, args: [target_class.new(id)], executor: Concurrent.configuration.global_task_pool ) end end def target_class @target_class ||= ActiveSupport::Inflector.constantize type end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aggro-0.0.4 | lib/aggro/channel.rb |
aggro-0.0.3 | lib/aggro/channel.rb |
aggro-0.0.2 | lib/aggro/channel.rb |