Sha256: 00e76c9bad82d9e12254073fb477adf815d66d5904cacddcdaadbb9c88cdd693

Contents?: true

Size: 1.47 KB

Versions: 10

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2024, by Samuel Williams.

require 'async/service/generic'
require 'async/http/endpoint'

require_relative '../service/server'
require_relative '../server'

module Falcon
	module Environment
		# Provides an environment for hosting a web application that uses a Falcon server.
		module Server
			# The service class to use for the proxy.
			# @returns [Class]
			def service_class
				Service::Server
			end
			
			# The server authority. Defaults to the server name.
			# @returns [String]
			def authority
				self.name
			end
			
			# Number of instances to start. By default (when nil), uses `Etc.nprocessors`.
			# @returns [Integer | nil]
			def count
				nil
			end
			
			# Options to use when creating the container.
			def container_options
				{restart: true, count: self.count}.compact
			end
			
			# The host that this server will receive connections for.
			def url
				"http://[::]:9292"
			end
			
			def timeout
				nil
			end
			
			# The upstream endpoint that will handle incoming requests.
			# @returns [Async::HTTP::Endpoint]
			def endpoint
				::Async::HTTP::Endpoint.parse(url).with(
					reuse_address: true,
					timeout: timeout,
				)
			end
			
			def verbose
				false
			end
			
			def cache
				false
			end
			
			def client_endpoint
				::Async::HTTP::Endpoint.parse(url)
			end
			
			# Any scripts to preload before starting the server.
			def preload
				[]
			end
		end
	end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
falcon-0.48.3 lib/falcon/environment/server.rb
falcon-0.48.2 lib/falcon/environment/server.rb
falcon-0.48.1 lib/falcon/environment/server.rb
falcon-0.48.0 lib/falcon/environment/server.rb
falcon-0.47.10 lib/falcon/environment/server.rb
falcon-0.47.9 lib/falcon/environment/server.rb
falcon-0.47.8 lib/falcon/environment/server.rb
falcon-0.47.7 lib/falcon/environment/server.rb
falcon-0.47.1 lib/falcon/environment/server.rb
falcon-0.47.0 lib/falcon/environment/server.rb