Class: Yeller::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/yeller/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(servers, token, startup_params, backtrace_filter, error_handler) ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
10
11
12
# File 'lib/yeller/client.rb', line 5

def initialize(servers, token, startup_params, backtrace_filter, error_handler)
  @servers = servers
  @last_server = rand(servers.size)
  @startup_params = startup_params
  @token = token
  @error_handler = error_handler
  @backtrace_filter = backtrace_filter
end

Instance Attribute Details

#backtrace_filterObject (readonly)

Returns the value of attribute backtrace_filter.



3
4
5
# File 'lib/yeller/client.rb', line 3

def backtrace_filter
  @backtrace_filter
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/yeller/client.rb', line 38

def enabled?
  true
end

#record_deploy(revision, user, environment) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/yeller/client.rb', line 30

def record_deploy(revision, user, environment)
  post = Net::HTTP::Post.new("/#{@token}/deploys")
  post.set_form_data('revision' => revision,
                     'user' => user,
                     'environment' => environment)
  next_server.client.request(post)
end

#report(exception, options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/yeller/client.rb', line 14

def report(exception, options={})
  hash = ExceptionFormatter.format(exception, backtrace_filter, options)
  serialized = JSON.dump(@startup_params.merge(hash))
  report_with_roundtrip(serialized, 0)
end

#report_with_roundtrip(serialized, error_count) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/yeller/client.rb', line 20

def report_with_roundtrip(serialized, error_count)
  next_server.client.post("/#{@token}", serialized, {"Content-Type" => "application/json"})
rescue StandardError => e
  if error_count <= (@servers.size * 2)
    report_with_roundtrip(serialized, error_count + 1)
  else
    @error_handler.handle(e)
  end
end