Class: ReactOnRailsPro::Configuration
- Inherits:
-
Object
- Object
- ReactOnRailsPro::Configuration
- Defined in:
- lib/react_on_rails_pro/configuration.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- DEFAULT_RENDERER_URL =
"http://localhost:3800"- DEFAULT_RENDERER_METHOD =
"ExecJS"- DEFAULT_RENDERER_FALLBACK_EXEC_JS =
true- DEFAULT_RENDERER_HTTP_POOL_SIZE =
Maximum concurrent HTTP/2 streams per persistent client. When Fiber.scheduler is available, clients are reused across requests within the same scheduler, making this limit effective. Without a scheduler, clients are per-request and this limits streams on that single request.
10- DEFAULT_RENDERER_HTTP_POOL_TIMEOUT =
TCP connect timeout. Request and response processing are still bounded by ssr_timeout.
5- DEFAULT_RENDERER_HTTP_POOL_WARN_TIMEOUT =
0.25- DEFAULT_RENDERER_HTTP_KEEP_ALIVE_TIMEOUT =
30- DEFAULT_SSR_TIMEOUT =
5- DEFAULT_PRERENDER_CACHING =
false- DEFAULT_TRACING =
false- DEFAULT_DEPENDENCY_GLOBS =
[].freeze
- DEFAULT_EXCLUDED_DEPENDENCY_GLOBS =
[].freeze
- DEFAULT_REMOTE_BUNDLE_CACHE_ADAPTER =
nil- DEFAULT_ROLLING_DEPLOY_ADAPTER =
nil- DEFAULT_ROLLING_DEPLOY_TOKEN =
nil- DEFAULT_ROLLING_DEPLOY_PREVIOUS_URL =
nil- DEFAULT_ROLLING_DEPLOY_MOUNT_PATH =
"/react_on_rails_pro/rolling_deploy"- ROLLING_DEPLOY_TOKEN_MIN_LENGTH =
Minimum bearer-token length when using the built-in HTTP rolling-deploy adapter. 32 chars matches SecureRandom.hex(16) and rules out obviously low-entropy values like “secret” or short app names without forcing a specific generator.
32- DEFAULT_RENDERER_REQUEST_RETRY_LIMIT =
5- DEFAULT_THROW_JS_ERRORS =
true- DEFAULT_RENDERING_RETURNS_PROMISES =
false- DEFAULT_PROFILE_SERVER_RENDERING_JS_CODE =
false- DEFAULT_RAISE_NON_SHELL_SERVER_RENDERING_ERRORS =
false- DEFAULT_ENABLE_RSC_SUPPORT =
false- DEFAULT_RSC_PAYLOAD_GENERATION_URL_PATH =
"rsc_payload/"- DEFAULT_RSC_BUNDLE_JS_FILE =
"rsc-bundle.js"- DEFAULT_REACT_CLIENT_MANIFEST_FILE =
"react-client-manifest.json"- DEFAULT_REACT_SERVER_CLIENT_MANIFEST_FILE =
"react-server-client-manifest.json"- DEFAULT_CONCURRENT_COMPONENT_STREAMING_BUFFER_SIZE =
64- ROLLING_DEPLOY_UPLOAD_POSITIONAL_PARAMS =
%i[req opt rest].freeze
- ROLLING_DEPLOY_UPLOAD_KEYWORD_PARAMS =
%i[key keyreq].freeze
- ROLLING_DEPLOY_UPLOAD_ALL_KEYWORD_PARAMS =
%i[keyrest].freeze
- ROLLING_DEPLOY_UPLOAD_REQUIRED_KEYWORDS =
%i[bundle assets].freeze
Instance Attribute Summary collapse
-
#assets_to_copy ⇒ Object
Returns the value of attribute assets_to_copy.
-
#concurrent_component_streaming_buffer_size ⇒ Object
Returns the value of attribute concurrent_component_streaming_buffer_size.
-
#dependency_globs ⇒ Object
Returns the value of attribute dependency_globs.
-
#enable_rsc_support ⇒ Object
Returns the value of attribute enable_rsc_support.
-
#excluded_dependency_globs ⇒ Object
Returns the value of attribute excluded_dependency_globs.
-
#prerender_caching ⇒ Object
Returns the value of attribute prerender_caching.
-
#profile_server_rendering_js_code ⇒ Object
Returns the value of attribute profile_server_rendering_js_code.
-
#raise_non_shell_server_rendering_errors ⇒ Object
Returns the value of attribute raise_non_shell_server_rendering_errors.
-
#react_client_manifest_file ⇒ Object
Returns the value of attribute react_client_manifest_file.
-
#react_server_client_manifest_file ⇒ Object
Returns the value of attribute react_server_client_manifest_file.
-
#remote_bundle_cache_adapter ⇒ Object
Returns the value of attribute remote_bundle_cache_adapter.
-
#renderer_http_keep_alive_timeout ⇒ Object
Returns the value of attribute renderer_http_keep_alive_timeout.
-
#renderer_http_pool_size ⇒ Object
Returns the value of attribute renderer_http_pool_size.
-
#renderer_http_pool_timeout ⇒ Object
Returns the value of attribute renderer_http_pool_timeout.
-
#renderer_http_pool_warn_timeout ⇒ Object
Returns the value of attribute renderer_http_pool_warn_timeout.
-
#renderer_password ⇒ Object
Returns the value of attribute renderer_password.
-
#renderer_request_retry_limit ⇒ Object
Returns the value of attribute renderer_request_retry_limit.
-
#renderer_url ⇒ Object
Returns the value of attribute renderer_url.
-
#renderer_use_fallback_exec_js ⇒ Object
Returns the value of attribute renderer_use_fallback_exec_js.
-
#rendering_returns_promises ⇒ Object
Returns the value of attribute rendering_returns_promises.
-
#rolling_deploy_adapter ⇒ Object
Returns the value of attribute rolling_deploy_adapter.
-
#rolling_deploy_mount_path ⇒ Object
Returns the value of attribute rolling_deploy_mount_path.
-
#rolling_deploy_previous_url ⇒ Object
Returns the value of attribute rolling_deploy_previous_url.
-
#rolling_deploy_token ⇒ Object
Returns the value of attribute rolling_deploy_token.
-
#rsc_bundle_js_file ⇒ Object
Returns the value of attribute rsc_bundle_js_file.
-
#rsc_payload_generation_url_path ⇒ Object
Returns the value of attribute rsc_payload_generation_url_path.
-
#server_renderer ⇒ Object
Returns the value of attribute server_renderer.
-
#ssr_pre_hook_js ⇒ Object
Returns the value of attribute ssr_pre_hook_js.
-
#ssr_timeout ⇒ Object
Returns the value of attribute ssr_timeout.
-
#throw_js_errors ⇒ Object
Returns the value of attribute throw_js_errors.
-
#tracing ⇒ Object
Returns the value of attribute tracing.
Instance Method Summary collapse
- #check_react_on_rails_support_for_rsc ⇒ Object
-
#initialize(renderer_url: nil, renderer_password: nil, server_renderer: nil, renderer_use_fallback_exec_js: nil, prerender_caching: nil, renderer_http_pool_size: nil, renderer_http_pool_timeout: nil, renderer_http_pool_warn_timeout: nil, renderer_http_keep_alive_timeout: nil, tracing: nil, dependency_globs: nil, excluded_dependency_globs: nil, rendering_returns_promises: nil, remote_bundle_cache_adapter: nil, rolling_deploy_adapter: nil, rolling_deploy_token: nil, rolling_deploy_previous_url: nil, rolling_deploy_mount_path: nil, ssr_pre_hook_js: nil, assets_to_copy: nil, renderer_request_retry_limit: nil, throw_js_errors: nil, ssr_timeout: nil, profile_server_rendering_js_code: nil, raise_non_shell_server_rendering_errors: nil, enable_rsc_support: nil, rsc_payload_generation_url_path: nil, rsc_bundle_js_file: nil, react_client_manifest_file: nil, react_server_client_manifest_file: nil, concurrent_component_streaming_buffer_size: DEFAULT_CONCURRENT_COMPONENT_STREAMING_BUFFER_SIZE) ⇒ Configuration
constructor
rubocop:disable Metrics/AbcSize.
- #node_renderer? ⇒ Boolean
-
#rolling_deploy_http_adapter? ⇒ Boolean
True when the configured rolling_deploy_adapter is the built-in HTTP adapter (or a subclass).
- #setup_config_values ⇒ Object
- #setup_execjs_profiler_if_needed ⇒ Object
Constructor Details
#initialize(renderer_url: nil, renderer_password: nil, server_renderer: nil, renderer_use_fallback_exec_js: nil, prerender_caching: nil, renderer_http_pool_size: nil, renderer_http_pool_timeout: nil, renderer_http_pool_warn_timeout: nil, renderer_http_keep_alive_timeout: nil, tracing: nil, dependency_globs: nil, excluded_dependency_globs: nil, rendering_returns_promises: nil, remote_bundle_cache_adapter: nil, rolling_deploy_adapter: nil, rolling_deploy_token: nil, rolling_deploy_previous_url: nil, rolling_deploy_mount_path: nil, ssr_pre_hook_js: nil, assets_to_copy: nil, renderer_request_retry_limit: nil, throw_js_errors: nil, ssr_timeout: nil, profile_server_rendering_js_code: nil, raise_non_shell_server_rendering_errors: nil, enable_rsc_support: nil, rsc_payload_generation_url_path: nil, rsc_bundle_js_file: nil, react_client_manifest_file: nil, react_server_client_manifest_file: nil, concurrent_component_streaming_buffer_size: DEFAULT_CONCURRENT_COMPONENT_STREAMING_BUFFER_SIZE) ⇒ Configuration
rubocop:disable Metrics/AbcSize
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/react_on_rails_pro/configuration.rb', line 162 def initialize(renderer_url: nil, renderer_password: nil, server_renderer: nil, # rubocop:disable Metrics/AbcSize renderer_use_fallback_exec_js: nil, prerender_caching: nil, renderer_http_pool_size: nil, renderer_http_pool_timeout: nil, renderer_http_pool_warn_timeout: nil, renderer_http_keep_alive_timeout: nil, tracing: nil, dependency_globs: nil, excluded_dependency_globs: nil, rendering_returns_promises: nil, remote_bundle_cache_adapter: nil, rolling_deploy_adapter: nil, rolling_deploy_token: nil, rolling_deploy_previous_url: nil, rolling_deploy_mount_path: nil, ssr_pre_hook_js: nil, assets_to_copy: nil, renderer_request_retry_limit: nil, throw_js_errors: nil, ssr_timeout: nil, profile_server_rendering_js_code: nil, raise_non_shell_server_rendering_errors: nil, enable_rsc_support: nil, rsc_payload_generation_url_path: nil, rsc_bundle_js_file: nil, react_client_manifest_file: nil, react_server_client_manifest_file: nil, concurrent_component_streaming_buffer_size: DEFAULT_CONCURRENT_COMPONENT_STREAMING_BUFFER_SIZE) self.renderer_url = renderer_url self.renderer_password = renderer_password self.server_renderer = server_renderer self.renderer_use_fallback_exec_js = renderer_use_fallback_exec_js self.prerender_caching = prerender_caching assign_initial_renderer_http_pool_size(renderer_http_pool_size) self.renderer_http_pool_timeout = renderer_http_pool_timeout self.renderer_http_pool_warn_timeout = renderer_http_pool_warn_timeout # Initial assignment applies the default constructor value; warn only when users set this deprecated config. assign_initial_renderer_http_keep_alive_timeout(renderer_http_keep_alive_timeout) self.tracing = tracing self.rendering_returns_promises = server_renderer == "NodeRenderer" ? rendering_returns_promises : false self.dependency_globs = dependency_globs self.excluded_dependency_globs = excluded_dependency_globs self.remote_bundle_cache_adapter = remote_bundle_cache_adapter self.rolling_deploy_adapter = rolling_deploy_adapter self.rolling_deploy_token = rolling_deploy_token self.rolling_deploy_previous_url = rolling_deploy_previous_url # Constructor nil/blank means "use the default"; configure-block assignment # can still set nil/blank later to opt out of the engine auto-mount. self.rolling_deploy_mount_path = rolling_deploy_mount_path.presence || DEFAULT_ROLLING_DEPLOY_MOUNT_PATH self.ssr_pre_hook_js = ssr_pre_hook_js self.assets_to_copy = assets_to_copy self.renderer_request_retry_limit = renderer_request_retry_limit self.throw_js_errors = throw_js_errors self.ssr_timeout = ssr_timeout self.profile_server_rendering_js_code = profile_server_rendering_js_code self.raise_non_shell_server_rendering_errors = raise_non_shell_server_rendering_errors self.enable_rsc_support = enable_rsc_support self.rsc_payload_generation_url_path = rsc_payload_generation_url_path self.rsc_bundle_js_file = rsc_bundle_js_file self.react_client_manifest_file = react_client_manifest_file self.react_server_client_manifest_file = react_server_client_manifest_file self.concurrent_component_streaming_buffer_size = concurrent_component_streaming_buffer_size end |
Instance Attribute Details
#assets_to_copy ⇒ Object
Returns the value of attribute assets_to_copy.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def assets_to_copy @assets_to_copy end |
#concurrent_component_streaming_buffer_size ⇒ Object
Returns the value of attribute concurrent_component_streaming_buffer_size.
112 113 114 |
# File 'lib/react_on_rails_pro/configuration.rb', line 112 def concurrent_component_streaming_buffer_size @concurrent_component_streaming_buffer_size end |
#dependency_globs ⇒ Object
Returns the value of attribute dependency_globs.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def dependency_globs @dependency_globs end |
#enable_rsc_support ⇒ Object
Returns the value of attribute enable_rsc_support.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def enable_rsc_support @enable_rsc_support end |
#excluded_dependency_globs ⇒ Object
Returns the value of attribute excluded_dependency_globs.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def excluded_dependency_globs @excluded_dependency_globs end |
#prerender_caching ⇒ Object
Returns the value of attribute prerender_caching.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def prerender_caching @prerender_caching end |
#profile_server_rendering_js_code ⇒ Object
Returns the value of attribute profile_server_rendering_js_code.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def profile_server_rendering_js_code @profile_server_rendering_js_code end |
#raise_non_shell_server_rendering_errors ⇒ Object
Returns the value of attribute raise_non_shell_server_rendering_errors.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def raise_non_shell_server_rendering_errors @raise_non_shell_server_rendering_errors end |
#react_client_manifest_file ⇒ Object
Returns the value of attribute react_client_manifest_file.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def react_client_manifest_file @react_client_manifest_file end |
#react_server_client_manifest_file ⇒ Object
Returns the value of attribute react_server_client_manifest_file.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def react_server_client_manifest_file @react_server_client_manifest_file end |
#remote_bundle_cache_adapter ⇒ Object
Returns the value of attribute remote_bundle_cache_adapter.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def remote_bundle_cache_adapter @remote_bundle_cache_adapter end |
#renderer_http_keep_alive_timeout ⇒ Object
Returns the value of attribute renderer_http_keep_alive_timeout.
112 113 114 |
# File 'lib/react_on_rails_pro/configuration.rb', line 112 def renderer_http_keep_alive_timeout @renderer_http_keep_alive_timeout end |
#renderer_http_pool_size ⇒ Object
Returns the value of attribute renderer_http_pool_size.
112 113 114 |
# File 'lib/react_on_rails_pro/configuration.rb', line 112 def renderer_http_pool_size @renderer_http_pool_size end |
#renderer_http_pool_timeout ⇒ Object
Returns the value of attribute renderer_http_pool_timeout.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def renderer_http_pool_timeout @renderer_http_pool_timeout end |
#renderer_http_pool_warn_timeout ⇒ Object
Returns the value of attribute renderer_http_pool_warn_timeout.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def renderer_http_pool_warn_timeout @renderer_http_pool_warn_timeout end |
#renderer_password ⇒ Object
Returns the value of attribute renderer_password.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def renderer_password @renderer_password end |
#renderer_request_retry_limit ⇒ Object
Returns the value of attribute renderer_request_retry_limit.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def renderer_request_retry_limit @renderer_request_retry_limit end |
#renderer_url ⇒ Object
Returns the value of attribute renderer_url.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def renderer_url @renderer_url end |
#renderer_use_fallback_exec_js ⇒ Object
Returns the value of attribute renderer_use_fallback_exec_js.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def renderer_use_fallback_exec_js @renderer_use_fallback_exec_js end |
#rendering_returns_promises ⇒ Object
Returns the value of attribute rendering_returns_promises.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def rendering_returns_promises @rendering_returns_promises end |
#rolling_deploy_adapter ⇒ Object
Returns the value of attribute rolling_deploy_adapter.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def rolling_deploy_adapter @rolling_deploy_adapter end |
#rolling_deploy_mount_path ⇒ Object
Returns the value of attribute rolling_deploy_mount_path.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def rolling_deploy_mount_path @rolling_deploy_mount_path end |
#rolling_deploy_previous_url ⇒ Object
Returns the value of attribute rolling_deploy_previous_url.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def rolling_deploy_previous_url @rolling_deploy_previous_url end |
#rolling_deploy_token ⇒ Object
Returns the value of attribute rolling_deploy_token.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def rolling_deploy_token @rolling_deploy_token end |
#rsc_bundle_js_file ⇒ Object
Returns the value of attribute rsc_bundle_js_file.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def rsc_bundle_js_file @rsc_bundle_js_file end |
#rsc_payload_generation_url_path ⇒ Object
Returns the value of attribute rsc_payload_generation_url_path.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def rsc_payload_generation_url_path @rsc_payload_generation_url_path end |
#server_renderer ⇒ Object
Returns the value of attribute server_renderer.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def server_renderer @server_renderer end |
#ssr_pre_hook_js ⇒ Object
Returns the value of attribute ssr_pre_hook_js.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def ssr_pre_hook_js @ssr_pre_hook_js end |
#ssr_timeout ⇒ Object
Returns the value of attribute ssr_timeout.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def ssr_timeout @ssr_timeout end |
#throw_js_errors ⇒ Object
Returns the value of attribute throw_js_errors.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def throw_js_errors @throw_js_errors end |
#tracing ⇒ Object
Returns the value of attribute tracing.
100 101 102 |
# File 'lib/react_on_rails_pro/configuration.rb', line 100 def tracing @tracing end |
Instance Method Details
#check_react_on_rails_support_for_rsc ⇒ Object
237 238 239 240 241 242 243 244 245 246 |
# File 'lib/react_on_rails_pro/configuration.rb', line 237 def check_react_on_rails_support_for_rsc return unless enable_rsc_support return if ReactOnRails::Utils.respond_to?(:rsc_support_enabled?) raise ReactOnRailsPro::Error, <<~MSG React Server Components (RSC) support requires react_on_rails version 15.0.0 or higher. Please upgrade your react_on_rails gem to enable this feature. MSG end |
#node_renderer? ⇒ Boolean
276 277 278 |
# File 'lib/react_on_rails_pro/configuration.rb', line 276 def node_renderer? ReactOnRailsPro.configuration.server_renderer == "NodeRenderer" end |
#rolling_deploy_http_adapter? ⇒ Boolean
True when the configured rolling_deploy_adapter is the built-in HTTP adapter (or a subclass). Used by the engine to decide whether to auto-mount the rolling-deploy bundles controller.
230 231 232 233 234 235 |
# File 'lib/react_on_rails_pro/configuration.rb', line 230 def rolling_deploy_http_adapter? adapter = rolling_deploy_adapter return false if adapter.nil? adapter.is_a?(Class) && adapter <= ReactOnRailsPro::RollingDeployAdapters::Http end |
#setup_config_values ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/react_on_rails_pro/configuration.rb', line 214 def setup_config_values configure_default_url_if_not_provided validate_url validate_remote_bundle_cache_adapter validate_rolling_deploy_adapter validate_rolling_deploy_http_adapter_config setup_renderer_password validate_renderer_password_for_production setup_assets_to_copy setup_execjs_profiler_if_needed check_react_on_rails_support_for_rsc end |
#setup_execjs_profiler_if_needed ⇒ Object
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/react_on_rails_pro/configuration.rb', line 248 def setup_execjs_profiler_if_needed return unless profile_server_rendering_js_code && server_renderer == "ExecJS" if ExecJS.runtime == ExecJS::Runtimes::Node ExecJS.runtime = ExecJS::ExternalRuntime.new( name: "Node.js (V8)", command: ["node --prof"], runner_path: "#{ExecJS.root}/support/node_runner.js", encoding: "UTF-8" ) elsif ExecJS.runtime == ExecJS::Runtimes::V8 ExecJS.runtime = ExecJS::ExternalRuntime.new( name: "V8", command: ["d8 --prof"], runner_path: "#{ExecJS.root}/support/v8_runner.js", encoding: "UTF-8" ) else current_runtime = ExecJS.runtime.name = <<~MSG You have set `profile_server_rendering_js_code` to true, but the current execjs runtime is #{current_runtime}. ExecJS profiler only supports Node.js (V8) or V8 runtimes. You can set the runtime by setting the `EXECJS_RUNTIME` environment variable to either `Node` or `V8`. MSG raise ReactOnRailsPro::Error, end end |