Sha256: dd98edf46953a6e3265db16e1f0f8f8c1773328b4a4589ce27c417089ae671a4

Contents?: true

Size: 500 Bytes

Versions: 10

Compression:

Stored size: 500 Bytes

Contents

# encoding: utf-8

module Kurchatov
  class Queue
    QUEUE_MAX_SIZE = 1_000

    def initialize
      @events = ::Queue.new
    end

    def <<(event)
      if @events.size >= QUEUE_MAX_SIZE
        drop = @events.shift
        Log.error("Drop event: #{drop.inspect}. See Kurchatov::Queue::QUEUE_MAX_SIZE")
      end
      @events << event
    end

    def all
      cur_events = Array.new
      until @events.empty?
        cur_events << @events.shift
      end
      cur_events
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kurchatov-0.0.6.pre.2 lib/kurchatov/queue.rb
kurchatov-0.0.6.pre.1 lib/kurchatov/queue.rb
kurchatov-0.0.5 lib/kurchatov/queue.rb
kurchatov-0.0.5.pre5 lib/kurchatov/queue.rb
kurchatov-0.0.5.pre4 lib/kurchatov/queue.rb
kurchatov-0.0.5.pre2 lib/kurchatov/queue.rb
kurchatov-0.0.5.pre1 lib/kurchatov/queue.rb
kurchatov-0.0.4 lib/kurchatov/queue.rb
kurchatov-0.0.4d lib/kurchatov/queue.rb
kurchatov-0.0.4c lib/kurchatov/queue.rb