Class: Syntropy::HTTP::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/syntropy/http/server.rb

Overview

HTTP::Server implements an HTTP server.

Constant Summary collapse

PENDING_REQUESTS_GRACE_PERIOD =
0.1
PENDING_REQUESTS_TIMEOUT_PERIOD =
5

Instance Method Summary collapse

Constructor Details

#initialize(machine, env, &app) ⇒ void

Initializes a server instance.

Parameters:

  • machine (UringMachine)

    machine instance

  • env (Hash)

    app environment

  • app (Proc, Syntropy::App)

    app instance



18
19
20
21
22
23
24
# File 'lib/syntropy/http/server.rb', line 18

def initialize(machine, env, &app)
  @machine = machine
  @env = env
  @app = app
  @server_fds = []
  @accept_fibers = []
end

Instance Method Details

#runvoid

This method returns an undefined value.

Runs the server.



29
30
31
32
33
34
# File 'lib/syntropy/http/server.rb', line 29

def run
  setup
  @machine.await(@accept_fibers)
rescue UM::Terminate
  graceful_shutdown
end

#stop!void

This method returns an undefined value.

Stops the server with graceful shutdown.



39
40
41
# File 'lib/syntropy/http/server.rb', line 39

def stop!
  graceful_shutdown
end