class Sentry::BackgroundWorker
Attributes
logger[R]
max_queue[R]
number_of_threads[R]
Public Class Methods
new(configuration)
click to toggle source
# File lib/sentry/background_worker.rb, line 11 def initialize(configuration) @max_queue = 30 @number_of_threads = configuration.background_worker_threads @logger = configuration.logger @executor = if configuration.async log_debug("config.async is set, BackgroundWorker is disabled") Concurrent::ImmediateExecutor.new elsif @number_of_threads == 0 log_debug("config.background_worker_threads is set to 0, all events will be sent synchronously") Concurrent::ImmediateExecutor.new else log_debug("initialized a background worker with #{@number_of_threads} threads") Concurrent::ThreadPoolExecutor.new( min_threads: 0, max_threads: @number_of_threads, max_queue: @max_queue, fallback_policy: :discard ) end end
Public Instance Methods
perform(&block)
click to toggle source
# File lib/sentry/background_worker.rb, line 35 def perform(&block) @executor.post do block.call end end