class

Logarithm::AsyncLogProcessor

Inherits Reference < Object

Asynchronous log processing with worker pool.

This class provides high-throughput log processing using a pool of worker fibers to process logs concurrently. It uses channels for communication between the main thread and worker threads.

Example usage:

processor = AsyncLogProcessor.new(workers: 4)
processor.start

# Submit logs for processing
logs.each do |log|
  processor.process(log)
end

results = processor.stop

Constructors

new(num_workers : Int32 = System.cpu_count.to_i32, queue_size : Int32 = 10000)
Source

Instance methods

current_queue_size

Get current queue size.

Source
num_workers
Source
process(entry : LogEntry)

Submit a log entry for processing.

Source
process_batch(entries : Array(LogEntry))

Submit multiple log entries for processing.

Source
processed_count

Get number of processed logs.

Source
queue_size
Source
running?

Check if processor is running.

Source
start

Start the async processor with worker pool.

Source
stop

Stop the processor and return results.

Source