Class: Radar::App::Server

Inherits:
Struct
  • Object
show all
Includes:
Logger
Defined in:
lib/radar/app/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

#logger

Instance Attribute Details

#portObject

Returns the value of attribute port

Returns:

  • (Object)

    the current value of port



5
6
7
# File 'lib/radar/app/server.rb', line 5

def port
  @port
end

Instance Method Details

#startObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/radar/app/server.rb', line 9

def start
  multiplexer = Thrift::MultiplexedProcessor.new
  analyzer_controller = Radar::App::AnalyzerController.new
  multiplexer.register_processor(
    'PortfolioAnalyzer',
    ProcessorFactory.create_processor(Radar::API::AnalyzerController::Processor).
      new(analyzer_controller)
  )
  unless Radar::App.transaction_importer.nil?
    multiplexer.register_processor(
      'TransactionImporter',
      ProcessorFactory.create_processor(Radar::API::TransactionImporter::Processor).
        new(Radar::App.transaction_importer)
    )
  end
  unless Radar::App.transaction_file_importer.nil?
    multiplexer.register_processor(
      'TransactionFileImporter',
      ProcessorFactory.create_processor(Radar::API::TransactionFileImporter::Processor).
        new(Radar::App.transaction_file_importer)
    )
  end
  transport = Thrift::ServerSocket.new(port)
  server = Thrift::NonblockingServer.new(multiplexer, transport, Thrift::FramedTransportFactory.new)
  logger.info { "Starting app on port #{port}..." }
  server.serve
end