Class: Aleph::Angstrom

Inherits:
Base
  • Object
show all
Defined in:
lib/angstrom.rb

Class Method Summary collapse

Methods inherited from Base

delete, get, head, patch, post, put, route

Class Method Details

.run!Object

the kicker. It all gets launched from here. this function makes a new connection object to handle the communication, promises to start the replier, request handler, and their supervisor, gives the replier the connection information, tells the request_handler what routes it should be able to match, then checks that all of the services are running correctly, gives us a launch time, then jumps into our main loop that waits for an incoming message, parses it, and sends it off to be operated on by the request handler. Boom.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/angstrom.rb', line 74

def self.run!
  #ensure that all actors are launched. Yea.
  done = Lazy::demand(Lazy::promise do |done|
    Actor.spawn(&Aleph::Base.supervisor_proc)
    done = true
  end)

  if done
    done2 = Lazy::demand(Lazy::Promise.new do |done2|
      Actor[:supervisor] << SpawnRequestHandlers.new(4)
      Actor[:supervisor] << SpawnReceivers.new(1)
      Actor[:supervisor] << AddRoutes.new(@routes)
      done2 = true
    end)
  end

  if Aleph::Base.supervisor && Aleph::Base.replier && done2
    puts "","="*56,"Angstrom has launched on #{Time.now}","="*56, ""
  end
  
  # main loop
  loop do
    gets
  end
end