class FunctionsFramework::Server::Config
The web server configuration. This object is yielded from the {FunctionsFramework::Server} constructor and can be modified at that point. Afterward, it is available from {FunctionsFramework::Server#config} but it is frozen.
Public Class Methods
Create a new config object with the default settings
# File lib/functions_framework/server.rb, line 200 def initialize self.rack_env = nil self.bind_addr = nil self.port = nil self.min_threads = nil self.max_threads = nil self.show_error_details = nil self.logger = nil end
Public Instance Methods
Returns the current bind address. @return [String]
# File lib/functions_framework/server.rb, line 284 def bind_addr @bind_addr end
Set the bind address, or `nil` to use the default. @param bind_addr
[String,nil]
# File lib/functions_framework/server.rb, line 223 def bind_addr= bind_addr @bind_addr = bind_addr || ::ENV["FUNCTION_BIND_ADDR"] || "0.0.0.0" end
Returns the logger. @return [Logger]
# File lib/functions_framework/server.rb, line 324 def logger @logger end
Set the logger for server messages, or `nil` to use the global default. @param logger [Logger]
# File lib/functions_framework/server.rb, line 268 def logger= logger @logger = logger || ::FunctionsFramework.logger end
Returns the maximum number of worker threads in the thread pool. @return [Integer]
# File lib/functions_framework/server.rb, line 308 def max_threads @max_threads || 1 end
Set the maximum number of worker threads, or `nil` to use the default. @param max_threads
[Integer,nil]
# File lib/functions_framework/server.rb, line 247 def max_threads= max_threads @max_threads = (max_threads || ::ENV["FUNCTION_MAX_THREADS"])&.to_i end
Returns the minimum number of worker threads in the thread pool. @return [Integer]
# File lib/functions_framework/server.rb, line 300 def min_threads @min_threads || 1 end
Set the minimum number of worker threads, or `nil` to use the default. @param min_threads
[Integer,nil]
# File lib/functions_framework/server.rb, line 239 def min_threads= min_threads @min_threads = (min_threads || ::ENV["FUNCTION_MIN_THREADS"])&.to_i end
Returns the current port number. @return [Integer]
# File lib/functions_framework/server.rb, line 292 def port @port end
Set the port number, or `nil` to use the default. @param port [Integer,nil]
# File lib/functions_framework/server.rb, line 231 def port= port @port = (port || ::ENV["PORT"] || 8080).to_i end
Returns the current Rack environment. @return [String]
# File lib/functions_framework/server.rb, line 276 def rack_env @rack_env end
Set the Rack environment, or `nil` to use the default. @param rack_env
[String,nil]
# File lib/functions_framework/server.rb, line 214 def rack_env= rack_env @rack_env = rack_env || ::ENV["RACK_ENV"] || (::ENV["K_REVISION"] ? "production" : "development") end
Set whether to show detailed error messages, or `nil` to use the default. @param show_error_details [Boolean,nil]
# File lib/functions_framework/server.rb, line 255 def show_error_details= show_error_details @show_error_details = if show_error_details.nil? !::ENV["FUNCTION_DETAILED_ERRORS"].to_s.empty? else show_error_details ? true : false end end
Returns whether to show detailed error messages. @return [Boolean]
# File lib/functions_framework/server.rb, line 316 def show_error_details? @show_error_details.nil? ? (@rack_env == "development") : @show_error_details end