Class: CitrusRpc::RpcServer::Server
- Inherits:
-
Object
- Object
- CitrusRpc::RpcServer::Server
- Includes:
- CitrusLoader, Utils::EventEmitter
- Defined in:
- lib/citrus-rpc/rpc-server/server.rb
Overview
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Server
constructor
Create a new rpc server.
-
#start ⇒ Object
Start the rpc server.
-
#stop ⇒ Object
Stop the rpc server.
Methods included from Utils::EventEmitter
Constructor Details
#initialize(args = {}) ⇒ Server
Create a new rpc server
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/citrus-rpc/rpc-server/server.rb', line 37 def initialize args={} raise ArgumentError, 'server port empty' unless args[:port] raise ArgumentError, 'server port must be bigger than zero' unless args[:port] > 0 raise ArgumentError, 'records empty' unless args[:records] raise ArgumentError, 'records must be an array' unless args[:records].respond_to? :to_a @services = {} create_namespace args[:records] load_remote_services args[:records], args[:context] args[:services] = @services @gateway = Gateway.new args @gateway.on(:error) { |*args| emit :error, *args } @gateway.on(:closed) { |*args| emit :closed, *args } end |
Instance Method Details
#start ⇒ Object
Start the rpc server
56 57 58 |
# File 'lib/citrus-rpc/rpc-server/server.rb', line 56 def start @gateway.start end |
#stop ⇒ Object
Stop the rpc server
61 62 63 |
# File 'lib/citrus-rpc/rpc-server/server.rb', line 61 def stop @gateway.stop end |