Sha256: 24937280c64643ae2a582300dbe66e86dd38288d3635f91cf8445cb5f69c9403
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
require 'drb' module Vedeu module Distributed # Orchestrates the running of the main application loop via the DRb server. # # @example # app = Vedeu::Distributed::Application.start(configuration) # app.input('a') # app.output # => some output # app.stop # # @api private class Application class << self # @param configuration [Vedeu::Configuration] # @return [] def start(configuration) new(configuration).start end end # @param configuration [Vedeu::Configuration] # @return [] def initialize(configuration) @configuration = configuration # $SAFE = 1 # stop eval and friends end # @return [] def start Vedeu.bind(:_output_) { |data| self.output(data) } Vedeu.log("Started distributed server: '#{uri}'") DRb.start_service(uri, self) self end # @param data [] # @return [] def input(data) Vedeu.log("<<< DRb Input") Vedeu.trigger(:_keypress_, data) end alias_method :read, :input # @param data [] # @return [] def output(data = nil) Vedeu.log(">>> DRb Output") data end alias_method :write, :output # @return [] def stop Vedeu.log("Stopping distributed server: '#{uri}'") DRb.stop_service DRb.thread.join rescue NoMethodError # raised when #join is called on NilClass. # ... end private attr_reader :configuration # @return [String] def uri Vedeu::Distributed::Uri.new(configuration.drb_host, configuration.drb_port).to_s end end # Application end # Distributed end # Vedeu
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.3.4 | lib/vedeu/distributed/application.rb |