Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize use of ENV.fetch for strings / numbers #49244

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion actionmailbox/test/dummy/config/cable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ test:

production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
url: <%= ENV.fetch("REDIS_URL", "redis://localhost:6379/1") %>
channel_prefix: dummy_production
2 changes: 1 addition & 1 deletion actionmailbox/test/dummy/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
timeout: 5000

development:
Expand Down
2 changes: 1 addition & 1 deletion actionmailbox/test/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# Info include generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). Use "debug"
# for everything.
config.log_level = ENV.fetch("RAILS_LOG_LEVEL") { "info" }
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
Expand Down
10 changes: 5 additions & 5 deletions actionmailbox/test/dummy/config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
min_threads_count = ENV.fetch("RAILS_MIN_THREADS", max_threads_count)
threads min_threads_count, max_threads_count

# Specifies that the worker count should equal the number of processors in production.
Expand All @@ -22,13 +22,13 @@
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch("PORT") { 3000 }
port ENV.fetch("PORT", 3000)

# Specifies the `environment` that Puma will run in.
environment ENV.fetch("RAILS_ENV") { "development" }
environment ENV.fetch("RAILS_ENV", "development")

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
pidfile ENV.fetch("PIDFILE", "tmp/pids/server.pid")

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
2 changes: 1 addition & 1 deletion actiontext/test/dummy/config/cable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ test:

production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
url: <%= ENV.fetch("REDIS_URL", "redis://localhost:6379/1") %>
channel_prefix: dummy_production
2 changes: 1 addition & 1 deletion actiontext/test/dummy/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
timeout: 5000

development:
Expand Down
2 changes: 1 addition & 1 deletion actiontext/test/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# Info include generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). Use "debug"
# for everything.
config.log_level = ENV.fetch("RAILS_LOG_LEVEL") { "info" }
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
Expand Down
10 changes: 5 additions & 5 deletions actiontext/test/dummy/config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
min_threads_count = ENV.fetch("RAILS_MIN_THREADS", max_threads_count)
threads min_threads_count, max_threads_count

# Specifies that the worker count should equal the number of processors in production.
Expand All @@ -22,13 +22,13 @@
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch("PORT") { 3000 }
port ENV.fetch("PORT", 3000)

# Specifies the `environment` that Puma will run in.
environment ENV.fetch("RAILS_ENV") { "development" }
environment ENV.fetch("RAILS_ENV", "development")

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
pidfile ENV.fetch("PIDFILE", "tmp/pids/server.pid")

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
2 changes: 1 addition & 1 deletion activestorage/test/dummy/config/cable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ test:

production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
url: <%= ENV.fetch("REDIS_URL", "redis://localhost:6379/1") %>
channel_prefix: dummy_production
2 changes: 1 addition & 1 deletion activestorage/test/dummy/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
timeout: 5000

development:
Expand Down
2 changes: 1 addition & 1 deletion activestorage/test/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# Info include generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). Use "debug"
# for everything.
config.log_level = ENV.fetch("RAILS_LOG_LEVEL") { "info" }
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
Expand Down
10 changes: 5 additions & 5 deletions activestorage/test/dummy/config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
min_threads_count = ENV.fetch("RAILS_MIN_THREADS", max_threads_count)
threads min_threads_count, max_threads_count

# Specifies that the worker count should equal the number of processors in production.
Expand All @@ -22,13 +22,13 @@
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch("PORT") { 3000 }
port ENV.fetch("PORT", 3000)

# Specifies the `environment` that Puma will run in.
environment ENV.fetch("RAILS_ENV") { "development" }
environment ENV.fetch("RAILS_ENV", "development")

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
pidfile ENV.fetch("PIDFILE", "tmp/pids/server.pid")

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def message_pack_pool
install_unregistered_type_handler
message_pack_factory.freeze
end
message_pack_factory.pool(ENV.fetch("RAILS_MAX_THREADS") { 5 })
message_pack_factory.pool(ENV.fetch("RAILS_MAX_THREADS", 5))
end
end

Expand Down
2 changes: 1 addition & 1 deletion guides/source/command_line.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ default: &default

# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>

development:
<<: *default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ test:

production:
adapter: redis
url: <%%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
url: <%%= ENV.fetch("REDIS_URL", "redis://localhost:6379/1") %>
channel_prefix: <%= app_name %>_production
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

default: &default
adapter: jdbc
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
username: <%= app_name %>
password:
driver:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
default: &default
adapter: mysql
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
username: root
password:
host: localhost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
default: &default
adapter: postgresql
encoding: unicode
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%%= ENV.fetch("RAILS_MAX_THREADS", 5) %>

development:
<<: *default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
default: &default
adapter: sqlite3
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%%= ENV.fetch("RAILS_MAX_THREADS", 5) %>

development:
<<: *default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
default: &default
adapter: mysql2
encoding: utf8mb4
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
username: root
password:
<% if mysql_socket -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
default: &default
adapter: oracle_enhanced
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
username: <%= app_name %>
password:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default: &default
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%%= ENV.fetch("RAILS_MAX_THREADS", 5) %>

development:
<<: *default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
default: &default
adapter: sqlite3
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
timeout: 5000

development:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
default: &default
adapter: trilogy
encoding: utf8mb4
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
username: root
password:
<% if mysql_socket -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
min_threads_count = ENV.fetch("RAILS_MIN_THREADS", max_threads_count)
threads min_threads_count, max_threads_count

# Specifies that the worker count should equal the number of processors in production.
Expand All @@ -22,13 +22,13 @@ end
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch("PORT") { 3000 }
port ENV.fetch("PORT", 3000)

# Specifies the `environment` that Puma will run in.
environment ENV.fetch("RAILS_ENV") { "development" }
environment ENV.fetch("RAILS_ENV", "development")

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
pidfile ENV.fetch("PIDFILE", "tmp/pids/server.pid")

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
4 changes: 2 additions & 2 deletions railties/test/application/dbconsole_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_use_value_defined_in_environment_file_in_database_yml
development:
database: <%= Rails.application.config.database %>
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
timeout: 5000
YAML

Expand All @@ -44,7 +44,7 @@ def test_respect_environment_option
app_file "config/database.yml", <<-YAML
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
timeout: 5000

development:
Expand Down