Module: Falcon::Environment::Server

Included in:
Application, Proxy, Redirect
Defined in:
lib/falcon/environment/server.rb

Overview

Provides an environment for hosting a web application that uses a Falcon server.

Instance Method Summary collapse

Instance Method Details

#authorityObject

The server authority. Defaults to the server name.



24
25
26
# File 'lib/falcon/environment/server.rb', line 24

def authority
	self.name
end

#cacheObject

Whether to enable the HTTP cache for this server.



73
74
75
# File 'lib/falcon/environment/server.rb', line 73

def cache
	false
end

#client_endpointObject

A client endpoint that can be used to connect to the server.



79
80
81
# File 'lib/falcon/environment/server.rb', line 79

def client_endpoint
	::Async::HTTP::Endpoint.parse(url)
end

#container_optionsObject

Options to use when creating the container.



35
36
37
38
39
40
41
# File 'lib/falcon/environment/server.rb', line 35

def container_options
	{
		restart: true,
		count: self.count,
		health_check_timeout: 30,
	}.compact
end

#countObject

Number of instances to start. By default (when nil), uses ‘Etc.nprocessors`.



30
31
32
# File 'lib/falcon/environment/server.rb', line 30

def count
	nil
end

#endpointObject

The upstream endpoint that will handle incoming requests.



63
64
65
# File 'lib/falcon/environment/server.rb', line 63

def endpoint
	::Async::HTTP::Endpoint.parse(url).with(**endpoint_options)
end

#endpoint_optionsObject

Options to use when creating the endpoint.



54
55
56
57
58
59
# File 'lib/falcon/environment/server.rb', line 54

def endpoint_options
	{
		reuse_address: true,
		timeout: self.timeout,
	}
end

#make_server(endpoint) ⇒ Object

Make a server instance using the given endpoint. The endpoint may be a bound endpoint, so we take care to specify the protocol and scheme as per the original endpoint.



94
95
96
# File 'lib/falcon/environment/server.rb', line 94

def make_server(endpoint)
	Falcon::Server.new(self.middleware, endpoint, protocol: self.endpoint.protocol, scheme: self.endpoint.scheme)
end

#preloadObject

Any scripts to preload before starting the server.



86
87
88
# File 'lib/falcon/environment/server.rb', line 86

def preload
	[]
end

#service_classObject

The service class to use for the proxy.



18
19
20
# File 'lib/falcon/environment/server.rb', line 18

def service_class
	Service::Server
end

#timeoutObject

The timeout used for client connections.



49
50
51
# File 'lib/falcon/environment/server.rb', line 49

def timeout
	nil
end

#urlObject

The host that this server will receive connections for.



44
45
46
# File 'lib/falcon/environment/server.rb', line 44

def url
	"http://[::]:9292"
end

#verboseObject

Whether to enable verbose logging.



68
69
70
# File 'lib/falcon/environment/server.rb', line 68

def verbose
	false
end