Class: Airbrake::AsyncSender Private

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrake-ruby/async_sender.rb

Overview

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.

Responsible for sending notices to Airbrake asynchronously.

See Also:

Since:

  • v1.0.0

Instance Method Summary collapse

Constructor Details

#initialize(method = :post, name = 'async-sender') ⇒ AsyncSender

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 AsyncSender.

Since:

  • v1.0.0



8
9
10
11
12
# File 'lib/airbrake-ruby/async_sender.rb', line 8

def initialize(method = :post, name = 'async-sender')
  @config = Airbrake::Config.instance
  @sync_sender = SyncSender.new(method)
  @name = name
end

Instance Method Details

#closevoid

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.

This method returns an undefined value.

Since:

  • v1.0.0



31
32
33
34
# File 'lib/airbrake-ruby/async_sender.rb', line 31

def close
  @sync_sender.close
  thread_pool.close
end

#closed?Boolean

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:

  • (Boolean)

Since:

  • v1.0.0



37
38
39
# File 'lib/airbrake-ruby/async_sender.rb', line 37

def closed?
  thread_pool.closed?
end

#has_workers?Boolean

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:

  • (Boolean)

Since:

  • v1.0.0



42
43
44
# File 'lib/airbrake-ruby/async_sender.rb', line 42

def has_workers?
  thread_pool.has_workers?
end

#send(data, promise, endpoint = @config.error_endpoint) ⇒ Airbrake::Promise

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.

Asynchronously sends a notice to Airbrake.

Parameters:

Returns:

Since:

  • v1.0.0



20
21
22
23
24
25
26
27
28
# File 'lib/airbrake-ruby/async_sender.rb', line 20

def send(data, promise, endpoint = @config.error_endpoint)
  unless thread_pool << [data, promise, endpoint]
    return promise.reject(
      "AsyncSender has reached its capacity of #{@config.queue_size}",
    )
  end

  promise
end