[PATCH v2 compass-ci] lib/sched_client.rb: obtain host port from the configuration file

[why] lib/sched_client.rb need host port of scheduler, obtain these values from the configuration file. [how] add SCHED_HOST SCHED_PORT on constants.rb Signed-off-by: Xiao Shenwei <xiaoshenwei96@163.com> --- lib/constants.rb | 3 +++ lib/sched_client.rb | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/constants.rb b/lib/constants.rb index ffc4f03..27f37cb 100644 --- a/lib/constants.rb +++ b/lib/constants.rb @@ -18,3 +18,6 @@ SRV_HTTP_DOMAIN = config['SRV_HTTP_DOMAIN'] || ENV['SRV_HTTP_DOMAIN'] || 'api.co ASSIST_RESULT_HOST = config['ASSIST_RESULT_HOST'] || ENV['ASSIST_RESULT_HOST'] || '172.17.0.1' ASSIST_RESULT_PORT = config['ASSIST_RESULT_PORT'] || ENV['ASSIST_RESULT_PORT'] || 8102 + +SCHED_HOST = config['SCHED_HOST'] || '172.17.0.1' +SCHED_PORT = config['SCHED_PORT'] || 3000 diff --git a/lib/sched_client.rb b/lib/sched_client.rb index f1c095d..fec4b14 100644 --- a/lib/sched_client.rb +++ b/lib/sched_client.rb @@ -3,12 +3,11 @@ # frozen_string_literal: true require 'rest-client' +require_relative 'constants' # sched client class class SchedClient - HOST = (ENV.key?('SCHED_HOST') ? ENV['SCHED_HOST'] : '172.17.0.1') - PORT = (ENV.key?('SCHED_PORT') ? ENV['SCHED_PORT'] : 3000).to_i - def initialize(host = HOST, port = PORT) + def initialize(host = SCHED_HOST, port = SCHED_PORT) @host = host @port = port end -- 2.23.0
participants (1)
-
Xiao Shenwei