Class: Dev2func::Shipper
- Inherits:
-
Object
- Object
- Dev2func::Shipper
- Defined in:
- lib/dev2func/shipper.rb
Constant Summary collapse
- DEFAULT_DOMAIN =
'http://localhost:8080'.freeze
- DEFAULT_ENDPOINT =
'/api/v1/streams'.freeze
- DEFAULT_API_DOMAIN =
'https://stream.dev2func.com'.freeze
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#container ⇒ Object
Returns the value of attribute container.
-
#faraday ⇒ Object
Returns the value of attribute faraday.
-
#stream ⇒ Object
Returns the value of attribute stream.
Instance Method Summary collapse
-
#initialize ⇒ Shipper
constructor
A new instance of Shipper.
-
#shipped(container) ⇒ Object
Sending stream to Dev2func API.
Constructor Details
#initialize ⇒ Shipper
Returns a new instance of Shipper.
12 13 14 15 16 17 |
# File 'lib/dev2func/shipper.rb', line 12 def initialize self.faraday = Faraday.new( url: DEFAULT_DOMAIN, headers: { 'Content-Type' => 'application/json' } ) end |
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
6 7 8 |
# File 'lib/dev2func/shipper.rb', line 6 def configuration @configuration end |
#container ⇒ Object
Returns the value of attribute container.
6 7 8 |
# File 'lib/dev2func/shipper.rb', line 6 def container @container end |
#faraday ⇒ Object
Returns the value of attribute faraday.
6 7 8 |
# File 'lib/dev2func/shipper.rb', line 6 def faraday @faraday end |
#stream ⇒ Object
Returns the value of attribute stream.
6 7 8 |
# File 'lib/dev2func/shipper.rb', line 6 def stream @stream end |
Instance Method Details
#shipped(container) ⇒ Object
Sending stream to Dev2func API
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dev2func/shipper.rb', line 20 def shipped(container) Rails.logger.info "[Dev2func] Ready to ship the container" self.container = container self.stream = self.container.stream self.configuration = self.container.configuration Rails.logger.info "[Dev2func] Stream content: #{self.stream}" Rails.logger.info "[Dev2func] Container content: #{self.configuration.project_token}" response = self.faraday.post("#{DEFAULT_API_DOMAIN}#{DEFAULT_ENDPOINT}") do |req| req.body = JSON.generate( ruby_version: self.configuration.platform_detail['ruby_version'], status: self.stream['status'].to_s, error_type: "internal server error", #internal server error, etc.. exception_type: self.stream['exception'], # #<StandardError: StandardError>, etc..", stream_type: 'errors', # info,errors,warning event: self.stream['traces']['Application Trace'].first['trace'], projects: { project_token: self.configuration.project_token }, # _backtrace = [] # self.stream['traces']['Framework Trace'].each do |ft| # _backtrace << ft["trace"] # end backtrace: self.stream['traces']['Framework Trace'].to_s, platform_detail: self.configuration.platform_detail.to_s ) end Rails.logger.info "status: #{response.status}" Rails.logger.info "body: #{response.body}" Rails.logger.info "[Dev2func] Success sending container" end |