Module: Scales::Server::Dispatch::Enqueue

Defined in:
lib/scales-server/dispatch/enqueue.rb

Class Method Summary collapse

Class Method Details

.request(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/scales-server/dispatch/enqueue.rb', line 7

def request(env)
  id  = create_random_id
  job = Request.to_job(id, env)
  
  Scales::Server.status.put_request_in_queue!(job)
  Storage::Async.add(Storage::REQUEST_QUEUE, JSON.generate(job))

  response = Response.subscribe(id)
  Scales::Server.status.took_response_from_queue!(response)
  response
end