@@ -3,16 +3,16 @@ module Stackify
33 class Configuration
44
55 attr_accessor :api_key , :app_name , :app_location , :env , :log_level , :logger ,
6- :proxy , :mode , :base_api_url , :api_enabled , :transport , :errors
6+ :proxy , :mode , :base_api_url , :api_enabled , :transport , :errors , :http_endpoint
77
8- attr_reader :send_interval , :flood_limit , :queue_max_size , :unix_socket_path , :unix_socket_url
8+ attr_reader :send_interval , :flood_limit , :queue_max_size , :agent_log_url , : unix_socket_path, :http_endpoint
99
1010 def initialize
1111 @base_api_url = 'https://api.stackify.com'
1212 @errors = [ ]
1313 @app_name = ''
1414 @api_key = ''
15- @transport = 'default'
15+ @transport = get_env 'STACKIFY_TRANSPORT' , 'default'
1616 @env = :production
1717 @flood_limit = 100
1818 @queue_max_size = 10000
@@ -22,23 +22,32 @@ def initialize
2222 @mode = MODES [ :both ]
2323 @logger = Logger . new ( STDOUT )
2424 @logger . level = Logger ::UNKNOWN
25+ @agent_log_url = '/log'
2526 @unix_socket_path = '/usr/local/stackify/stackify.sock'
26- @unix_socket_url = '/log'
27+ @http_endpoint = get_env 'STACKIFY_TRANSPORT_HTTP_ENDPOINT' , 'https://localhost:10601'
28+ end
29+
30+ def get_env env_key , default
31+ value = default
32+ if ENV . keys . include? env_key
33+ value = ENV [ env_key ]
34+ end
35+ return value
2736 end
2837
2938 def is_valid?
3039 case Stackify . configuration . transport
3140 when Stackify ::DEFAULT
3241 validate_default_transport
33- when Stackify ::UNIX_SOCKET
34- validate_unix_domain_socket_transport
42+ when Stackify ::UNIX_SOCKET , Stackify :: AGENT_HTTP
43+ validate_agent_transport
3544 end
3645 @errors . empty?
3746 end
3847
3948 def validate_transport_type
40- return true if [ 'agent_socket' , 'default' ] . include? @transport
41- @errors << 'Transport should be one of these values: [agent_socket, default]. Should be a String.'
49+ return true if [ 'agent_socket' , 'agent_http' , ' default'] . include? @transport
50+ @errors << 'Transport should be one of these values: [agent_socket, agent_http, default]. Should be a String.'
4251 end
4352
4453 private
@@ -60,9 +69,9 @@ def validate_default_transport
6069 validate_mode_type
6170 end
6271
63- # Perform validation if transport type is agent_socket
72+ # Perform validation if transport type is agent_socket or agent_http
6473 # Required parameters are: env, app_name, log_level
65- def validate_unix_domain_socket_transport
74+ def validate_agent_transport
6675 validate_env &&
6776 validate_transport_type &&
6877 validate_app_name &&
0 commit comments