Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# 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.
thread_count = Sagittarius::Configuration.config[:rails][:threads]
# Default is set to 5 threads for minimum and maximum; this matches the default
# thread size of Active Record.
thread_count = Sagittarius::Configuration.config[:rails][:web][:threads]
threads thread_count, thread_count

# Specifies that the worker count should equal the number of processors in production.
Expand Down
3 changes: 2 additions & 1 deletion config/sagittarius.example.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
rails:
threads: 3
log_level: info
mailer:
from: Code0 <testmail@code0.tech>
Expand All @@ -9,10 +8,12 @@ rails:
username: testmail@code0.tech
password: changeme
web:
threads: 3
port: 3000
bind: # For example: tcp://0.0.0.0:3000
force_ssl:
grpc:
threads: 3
host: '0.0.0.0:50051'
db:
host: localhost
Expand Down
3 changes: 2 additions & 1 deletion lib/sagittarius/configuration.rb

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires changes in the config-generator in reticulum, so lets wait until the next canary is finished

Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ def self.application_setting_overrides
def self.defaults
{
rails: {
threads: 3,
web: {
threads: 3,
port: 3000,
force_ssl: nil,
bind: nil,
},
grpc: {
threads: 3,
host: '0.0.0.0:50051',
},
log_level: 'info',
Expand Down
2 changes: 1 addition & 1 deletion lib/sagittarius/grpc/launcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def create_server
Sagittarius::Middleware::Grpc::Context.new,
Sagittarius::Middleware::Grpc::Logger.new,
Sagittarius::Middleware::Grpc::Authentication.new
].reverse, pool_size: Configuration.config[:rails][:threads])
].reverse, pool_size: Configuration.config[:rails][:grpc][:threads])
logger.info('GRPC server created')

@server.add_http2_port(HOST, :this_port_is_insecure)
Expand Down
12 changes: 10 additions & 2 deletions spec/lib/sagittarius/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
let(:yaml_config) do
<<~CONFIG
rails:
threads: 4
web:
threads: 4
grpc:
threads: 8
CONFIG
end

Expand All @@ -20,7 +23,12 @@
end

it 'loads the config' do
expect(described_class.config).to include(rails: a_hash_including(threads: 4))
expect(described_class.config).to include(
rails: a_hash_including(
web: a_hash_including(threads: 4),
grpc: a_hash_including(threads: 8)
)
)
end
end

Expand Down