Class: CortexClient::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/cortex_client/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



6
7
8
9
10
11
12
13
14
# File 'lib/cortex_client/configuration.rb', line 6

def initialize
  @host = ''
  @token = ''
  @metrics_push_api_path = ''
  @read_timeout = 75
  @connect_timeout = 10
  @write_timeout = 75
  @agents = [Http::Agent.new(name: CortexClient.name, version: CortexClient::VERSION)]
end

Instance Attribute Details

#agentsObject (readonly)

Returns the value of attribute agents.



4
5
6
# File 'lib/cortex_client/configuration.rb', line 4

def agents
  @agents
end

#connect_timeoutObject (readonly)

Returns the value of attribute connect_timeout.



4
5
6
# File 'lib/cortex_client/configuration.rb', line 4

def connect_timeout
  @connect_timeout
end

#hostObject

Returns the value of attribute host.



3
4
5
# File 'lib/cortex_client/configuration.rb', line 3

def host
  @host
end

#metrics_push_api_pathObject

Returns the value of attribute metrics_push_api_path.



3
4
5
# File 'lib/cortex_client/configuration.rb', line 3

def metrics_push_api_path
  @metrics_push_api_path
end

#read_timeoutObject (readonly)

Returns the value of attribute read_timeout.



4
5
6
# File 'lib/cortex_client/configuration.rb', line 4

def read_timeout
  @read_timeout
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/cortex_client/configuration.rb', line 3

def token
  @token
end

#write_timeoutObject (readonly)

Returns the value of attribute write_timeout.



4
5
6
# File 'lib/cortex_client/configuration.rb', line 4

def write_timeout
  @write_timeout
end

Instance Method Details

#agentObject



28
29
30
# File 'lib/cortex_client/configuration.rb', line 28

def agent
  Http::Agent.list_to_s(@agents)
end

#agent=(agent_attributes) ⇒ Object



24
25
26
# File 'lib/cortex_client/configuration.rb', line 24

def agent=(agent_attributes)
  @agents.push(Http::Agent.new(agent_attributes))
end

#valid?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
# File 'lib/cortex_client/configuration.rb', line 16

def valid?
  !@token.empty? &&
      !@host.empty? &&
      !@host.end_with?('/') &&
      !@metrics_push_api_path.empty? &&
      !@metrics_push_api_path.start_with?('/')
end