Sha256: b5da13cba76be1f3e12227b0ceb23c87d2bef3e64f351a54c91a8a99cd179786
Contents?: true
Size: 1.6 KB
Versions: 2
Compression:
Stored size: 1.6 KB
Contents
module Orchestrator module Core class RequestsProxy def initialize(thread, modules) if modules.nil? @modules = [] else @modules = modules.is_a?(Array) ? modules : [modules] end @thread = thread end # Returns true if there is no object to proxy # # @return [true|false] def nil? @modules.empty? end alias_method :empty?, :nil? def method_missing(name, *args, &block) if ::Orchestrator::Core::PROTECTED[name] err = Error::ProtectedMethod.new "attempt to access a protected method '#{name}' in multiple modules" ::Libuv::Q.reject(@thread, err) # TODO:: log warning err.message else promises = @modules.map do |mod| defer = mod.thread.defer mod.thread.schedule do begin defer.resolve( mod.instance.public_send(name, *args, &block) ) rescue => e mod.logger.print_error(e) defer.reject(e) end end defer.promise end @thread.finally(*promises) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
orchestrator-1.0.2 | lib/orchestrator/core/requests_proxy.rb |
orchestrator-1.0.1 | lib/orchestrator/core/requests_proxy.rb |