Sha256: 2d3520ff3c925135862876449de8a26f5d48b4b04710f2f0ffb38133480134c3
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 KB
Contents
require "concurrent/executor/thread_pool_executor" require "concurrent/executor/immediate_executor" require "concurrent/configuration" module Sentry class BackgroundWorker attr_reader :max_queue, :number_of_threads def initialize(configuration) @max_queue = 30 @number_of_threads = configuration.background_worker_threads @executor = if configuration.async configuration.logger.debug(LOGGER_PROGNAME) { "config.async is set, BackgroundWorker is disabled" } Concurrent::ImmediateExecutor.new elsif @number_of_threads == 0 configuration.logger.debug(LOGGER_PROGNAME) { "config.background_worker_threads is set to 0, all events will be sent synchronously" } Concurrent::ImmediateExecutor.new else configuration.logger.debug(LOGGER_PROGNAME) { "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 def perform(&block) @executor.post do block.call end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sentry-ruby-core-4.3.2 | lib/sentry/background_worker.rb |
sentry-ruby-core-4.3.1 | lib/sentry/background_worker.rb |
sentry-ruby-core-4.3.0 | lib/sentry/background_worker.rb |