Skip to content

Commit

Permalink
Add ES request_timeout env var
Browse files Browse the repository at this point in the history
This is to set a slightly higher default and allow override on ENV.
  • Loading branch information
richardhallett committed Sep 16, 2020
1 parent a504db4 commit 778ee2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 5 additions & 4 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
ENV['MYSQL_PASSWORD'] ||= ""
ENV['MYSQL_HOST'] ||= "mysql"
ENV['MYSQL_PORT'] ||= "3306"
ENV['ES_REQUEST_TIMEOUT'] ||= "120"
ENV['ES_HOST'] ||= "elasticsearch:9200"
ENV['ES_NAME'] ||= "elasticsearch"
ENV['ES_SCHEME'] ||= "http"
Expand All @@ -71,7 +72,7 @@ class Application < Rails::Application
config.paths.add Rails.root.join('app', 'graphql', 'mutations').to_s, eager_load: true
config.paths.add Rails.root.join('app', 'graphql', 'connections').to_s, eager_load: true
config.paths.add Rails.root.join('app', 'graphql', 'resolvers').to_s, eager_load: true

# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
Expand All @@ -84,7 +85,7 @@ class Application < Rails::Application
# secret_key_base is not used by Rails API, as there are no sessions
config.secret_key_base = "blipblapblup"

# enable datadog tracing here so that we can inject tracing
# enable datadog tracing here so that we can inject tracing
# information into logs
Datadog.configure do |c|
c.tracer hostname: "datadog.local", enabled: Rails.env.production?, env: Rails.env
Expand Down Expand Up @@ -116,7 +117,7 @@ class Application < Rails::Application
correlation = Datadog.tracer.active_correlation

exceptions = %w(controller action format id)

{
# Adds IDs as tags to log output
dd: {
Expand Down Expand Up @@ -158,7 +159,7 @@ class Application < Rails::Application
end

# use SQS based on environment, use "test" prefix for test system
if Rails.env == "stage"
if Rails.env == "stage"
config.active_job.queue_name_prefix = ENV['ES_PREFIX'].present? ? "stage" : "test"
else
config.active_job.queue_name_prefix = Rails.env
Expand Down
7 changes: 6 additions & 1 deletion config/initializers/elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
require 'faraday_middleware/aws_sigv4'

if ENV['ES_HOST'] == "elasticsearch.test.datacite.org" || ENV['ES_HOST'] == "elasticsearch.datacite.org"
Elasticsearch::Model.client = Elasticsearch::Client.new(host: ENV['ES_HOST'], port: '80', scheme: 'http') do |f|
Elasticsearch::Model.client = Elasticsearch::Client.new(
host: ENV['ES_HOST'],
port: '80',
scheme: 'http',
request_timeout: ENV['ES_REQUEST_TIMEOUT']
) do |f|
f.request :aws_sigv4,
credentials: Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']),
service: 'es',
Expand Down

0 comments on commit 778ee2e

Please sign in to comment.