This allows you to easily have many background processes running asynchronously without having
threads piling up in the host program, which can affect performance. If you need more complex communication
than a simple triggering of some action, then using a more sophisticated communications method, such
as is provided by your operating system or programming language, is a good idea. (Conceivably, you could
embed an entire RESTful web application inside your desktop application, but that may be overkill.)
After you define the two classes that make up the bulk of your functionality, you start
the server running:
stocks_list = StocksList.new
stocks_list.load_csv(ARGV)
interface = '127.0.0.1'
port = '3000'
mongrel_server = Mongrel::HttpServer.new( interface, port)
mongrel_server.register("/", StocksListHandler.new(stocks_list))
puts "** Fidelity XML server started on #{interface}:#{port}!"
mongrel_server.run.join
The first line grabs a list of files from the command line and creates a new StocksList
object. Then you call the load_csv method, which causes the list of symbols to be loaded
from the CSV files.
Pages:
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260