Class: Hoss::Transport::Connection Private
- Inherits:
-
Object
- Object
- Hoss::Transport::Connection
- Includes:
- Logging
- Defined in:
- lib/hoss/transport/connection.rb,
lib/hoss/transport/connection/http.rb,
lib/hoss/transport/connection/proxy_pipe.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Constant Summary
Constants included from Logging
Logging::LEVELS, Logging::PREFIX
Instance Attribute Summary collapse
- #http ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(config) ⇒ Connection
constructor
private
A new instance of Connection.
- #write(str) ⇒ Object private
Methods included from Logging
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(config) ⇒ Connection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Connection.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/hoss/transport/connection.rb', line 26 def initialize(config) @config = config @metadata = JSON.fast_generate( Serializers::MetadataSerializer.new(config).build( Metadata.new(config) ) ) @url = @config.ingress_host @mutex = Mutex.new end |
Instance Attribute Details
#http ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 |
# File 'lib/hoss/transport/connection.rb', line 37 def http @http end |
Instance Method Details
#write(str) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/hoss/transport/connection.rb', line 38 def write(str) debug "Sending report" uri = URI(@url) req = Net::HTTP::Post.new( uri, 'Authorization' => "Bearer #{@config.api_key}", #"Basic " + Base64.encode64("#{@config.api_key}:"), 'Content-Type' => 'application/json', 'HOSS-SKIP-INSTRUMENTATION' => 'true', ) req.body = str res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') do |http| http.request(req) end raise unless res.code == "200" end |