lib/protobuf/cli.rb in protobuf-2.8.13 vs lib/protobuf/cli.rb in protobuf-3.0.0.rc1

- old
+ new

@@ -1,9 +1,8 @@ require 'thor' require 'protobuf/version' require 'protobuf/logger' -require 'protobuf/rpc/servers/evented_runner' require 'protobuf/rpc/servers/socket_runner' require 'protobuf/rpc/servers/zmq_runner' module Protobuf class CLI < ::Thor @@ -24,11 +23,10 @@ option :log, :type => :string, :aliases => %w(-l), :desc => 'Log file or device. Default is STDOUT.' option :level, :type => :numeric, :default => ::Logger::INFO, :aliases => %w(-v), :desc => 'Log level to use, 0-5 (see http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/)' option :socket, :type => :boolean, :aliases => %w(-s), :desc => 'Socket Mode for server and client connections.' - option :evented, :type => :boolean, :aliases => %w(-m), :desc => 'Evented Mode for server and client connections (uses EventMachine).' option :zmq, :type => :boolean, :aliases => %w(-z), :desc => 'ZeroMQ Socket Mode for server and client connections.' option :beacon_interval, :type => :numeric, :desc => 'Broadcast beacons every N seconds. (default: 5)' option :beacon_port, :type => :numeric, :desc => 'Broadcast beacons to this port (default: value of ServiceDirectory.port)' option :broadcast_beacons, :type => :boolean, :desc => 'Broadcast beacons for dynamic discovery (Currently only available with ZeroMQ).' @@ -57,11 +55,11 @@ say_and_exit('ERROR: RPC Server failed to start.', e) end desc 'version', 'Print ruby and protoc versions and exit.' def version - say("Ruby Protobuf v#{::Protobuf::VERSION}, protoc v#{::Protobuf::PROTOC_VERSION}") + say("Ruby Protobuf v#{::Protobuf::VERSION}") end no_tasks do # Tell protobuf how to handle the printing of deprecated field usage. @@ -109,20 +107,16 @@ if multi_mode? say('WARNING: You have provided multiple mode options. Defaulting to socket mode.', :yellow) @runner_mode = :socket elsif options.zmq? @runner_mode = :zmq - elsif options.evented? - @runner_mode = :evented else case server_type = ENV["PB_SERVER_TYPE"] when nil, /socket/i @runner_mode = :socket when /zmq/i @runner_mode = :zmq - when /evented/i - @runner_mode = :evented else say "WARNING: You have provided incorrect option 'PB_SERVER_TYPE=#{server_type}'. Defaulting to socket mode.", :yellow @runner_mode = :socket end end @@ -148,12 +142,10 @@ # Create the runner for the configured mode def create_runner debug_say("Creating #{@runner_mode} runner") @runner = case @runner_mode - when :evented - create_evented_runner when :zmq create_zmq_runner when :socket create_socket_runner else @@ -170,15 +162,11 @@ !!@exit_requested end # Internal helper to determine if the modes are multi-set which is not valid. def multi_mode? - [ - options.zmq?, - options.evented?, - options.socket?, - ].count(true) > 1 + options.zmq? && options.socket? end # Require the application file given, exiting if the file doesn't exist. def require_application(app_file) debug_say('Requiring app file') @@ -207,15 +195,9 @@ ::Protobuf::Logger.error { "[#{exception.class.name}] #{exception.message}" } ::Protobuf::Logger.debug { exception.backtrace.join("\n") } end exit(1) - end - - def create_evented_runner - require 'protobuf/evented' - - @runner = ::Protobuf::Rpc::EventedRunner.new(runner_options) end def create_socket_runner require 'protobuf/socket'