Class: GraphiteAPI::Connector
- Inherits:
-
Object
- Object
- GraphiteAPI::Connector
- Defined in:
- lib/graphite-api/connector.rb
Defined Under Namespace
Classes: Group
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#check! ⇒ Object
Manually init Socket, exception will be thrown on error.
-
#initialize(uri) ⇒ Connector
constructor
A new instance of Connector.
- #inspect ⇒ Object
- #puts(message) ⇒ Object
Constructor Details
#initialize(uri) ⇒ Connector
Returns a new instance of Connector.
8 9 10 11 12 |
# File 'lib/graphite-api/connector.rb', line 8 def initialize uri @uri = URI.parse uri @uri = @uri.host ? @uri : URI.parse("udp://#{uri}") @socket = nil end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/graphite-api/connector.rb', line 6 def uri @uri end |
Instance Method Details
#check! ⇒ Object
Manually init Socket, exception will be thrown on error
30 31 32 |
# File 'lib/graphite-api/connector.rb', line 30 def check! socket; nil end |
#inspect ⇒ Object
25 26 27 |
# File 'lib/graphite-api/connector.rb', line 25 def inspect "#<#{self.class}:#{object_id}: #{@uri}>" end |
#puts(message) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/graphite-api/connector.rb', line 14 def puts counter = 0 begin Logger.debug [:connector, :puts, @uri.to_s, ] socket.puts + "\n" rescue Exception @socket = nil (counter += 1) <= 5 ? retry : raise end end |