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
149 150 151 152 153 154 155 156 157 158 159 160 161 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 |
# File 'lib/react_on_rails_pro/configuration.rb', line 149 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 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.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def assets_to_copy @assets_to_copy end |
#concurrent_component_streaming_buffer_size ⇒ Object
Returns the value of attribute concurrent_component_streaming_buffer_size.
99 100 101 |
# File 'lib/react_on_rails_pro/configuration.rb', line 99 def concurrent_component_streaming_buffer_size @concurrent_component_streaming_buffer_size end |
#dependency_globs ⇒ Object
Returns the value of attribute dependency_globs.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def dependency_globs @dependency_globs end |
#enable_rsc_support ⇒ Object
Returns the value of attribute enable_rsc_support.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def enable_rsc_support @enable_rsc_support end |
#excluded_dependency_globs ⇒ Object
Returns the value of attribute excluded_dependency_globs.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def excluded_dependency_globs @excluded_dependency_globs end |
#prerender_caching ⇒ Object
Returns the value of attribute prerender_caching.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def prerender_caching @prerender_caching end |
#profile_server_rendering_js_code ⇒ Object
Returns the value of attribute profile_server_rendering_js_code.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 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.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 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.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 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.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 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.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 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.
99 100 101 |
# File 'lib/react_on_rails_pro/configuration.rb', line 99 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.
99 100 101 |
# File 'lib/react_on_rails_pro/configuration.rb', line 99 def renderer_http_pool_size @renderer_http_pool_size end |
#renderer_http_pool_timeout ⇒ Object
Returns the value of attribute renderer_http_pool_timeout.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 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.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def renderer_http_pool_warn_timeout @renderer_http_pool_warn_timeout end |
#renderer_password ⇒ Object
Returns the value of attribute renderer_password.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def renderer_password @renderer_password end |
#renderer_request_retry_limit ⇒ Object
Returns the value of attribute renderer_request_retry_limit.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def renderer_request_retry_limit @renderer_request_retry_limit end |
#renderer_url ⇒ Object
Returns the value of attribute renderer_url.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def renderer_url @renderer_url end |
#renderer_use_fallback_exec_js ⇒ Object
Returns the value of attribute renderer_use_fallback_exec_js.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def renderer_use_fallback_exec_js @renderer_use_fallback_exec_js end |
#rendering_returns_promises ⇒ Object
Returns the value of attribute rendering_returns_promises.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def rendering_returns_promises @rendering_returns_promises end |
#rolling_deploy_adapter ⇒ Object
Returns the value of attribute rolling_deploy_adapter.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def rolling_deploy_adapter @rolling_deploy_adapter end |
#rolling_deploy_mount_path ⇒ Object
Returns the value of attribute rolling_deploy_mount_path.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def rolling_deploy_mount_path @rolling_deploy_mount_path end |
#rolling_deploy_previous_url ⇒ Object
Returns the value of attribute rolling_deploy_previous_url.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def rolling_deploy_previous_url @rolling_deploy_previous_url end |
#rolling_deploy_token ⇒ Object
Returns the value of attribute rolling_deploy_token.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def rolling_deploy_token @rolling_deploy_token end |
#rsc_bundle_js_file ⇒ Object
Returns the value of attribute rsc_bundle_js_file.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 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.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def rsc_payload_generation_url_path @rsc_payload_generation_url_path end |
#server_renderer ⇒ Object
Returns the value of attribute server_renderer.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def server_renderer @server_renderer end |
#ssr_pre_hook_js ⇒ Object
Returns the value of attribute ssr_pre_hook_js.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def ssr_pre_hook_js @ssr_pre_hook_js end |
#ssr_timeout ⇒ Object
Returns the value of attribute ssr_timeout.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def ssr_timeout @ssr_timeout end |
#throw_js_errors ⇒ Object
Returns the value of attribute throw_js_errors.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def throw_js_errors @throw_js_errors end |
#tracing ⇒ Object
Returns the value of attribute tracing.
87 88 89 |
# File 'lib/react_on_rails_pro/configuration.rb', line 87 def tracing @tracing end |
Instance Method Details
#check_react_on_rails_support_for_rsc ⇒ Object
222 223 224 225 226 227 228 229 230 231 |
# File 'lib/react_on_rails_pro/configuration.rb', line 222 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
261 262 263 |
# File 'lib/react_on_rails_pro/configuration.rb', line 261 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.
215 216 217 218 219 220 |
# File 'lib/react_on_rails_pro/configuration.rb', line 215 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
199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/react_on_rails_pro/configuration.rb', line 199 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
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/react_on_rails_pro/configuration.rb', line 233 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 |