module Falcon::Environment::Server

def authority

@returns [String]
The server authority. Defaults to the server name.
def authority
	self.name
end

def cache

Whether to enable the HTTP cache for this server.
def cache
	false
end

def client_endpoint

@returns [Async::HTTP::Endpoint] The client endpoint.
A client endpoint that can be used to connect to the server.
def client_endpoint
	::Async::HTTP::Endpoint.parse(url)
end

def container_options

Options to use when creating the container.
def container_options
	{
		restart: true,
		count: self.count,
		health_check_timeout: 30,
	}.compact
end

def count

@returns [Integer | nil]
Number of instances to start. By default (when nil), uses `Etc.nprocessors`.
def count
	nil
end

def endpoint

@returns [Async::HTTP::Endpoint]
The upstream endpoint that will handle incoming requests.
def endpoint
	::Async::HTTP::Endpoint.parse(url).with(**endpoint_options)
end

def endpoint_options

Options to use when creating the endpoint.
def endpoint_options
	{
		reuse_address: true,
		timeout: self.timeout,
	}
end

def make_server(endpoint)

@returns [Falcon::Server] The server instance.
@parameter endpoint [IO::Endpoint] The endpoint to bind to.

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.
def make_server(endpoint)
	Falcon::Server.new(self.middleware, endpoint, protocol: self.endpoint.protocol, scheme: self.endpoint.scheme)
end

def preload

@returns [Array(String)] The list of scripts to preload.

Any scripts to preload before starting the server.
def preload
	[]
end

def service_class

@returns [Class]
The service class to use for the proxy.
def service_class
	Service::Server
end

def timeout

The timeout used for client connections.
def timeout
	nil
end

def url

The host that this server will receive connections for.
def url
	"http://[::]:9292"
end

def verbose

Whether to enable verbose logging.
def verbose
	false
end