Class: OpenWFE::Journal::Bucket

Inherits:
Object
  • Object
show all
Defined in:
lib/openwfe/expool/journal.rb

Overview

for each process instance, there is one bucket holding the events waiting to get written in the journal

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Bucket

Returns a new instance of Bucket.



196
197
198
199
200
# File 'lib/openwfe/expool/journal.rb', line 196

def initialize (path)
    super()
    @path = path
    @events = []
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



194
195
196
# File 'lib/openwfe/expool/journal.rb', line 194

def events
  @events
end

#pathObject (readonly)

Returns the value of attribute path.



194
195
196
# File 'lib/openwfe/expool/journal.rb', line 194

def path
  @path
end

Instance Method Details

#<<(event) ⇒ Object



202
203
204
# File 'lib/openwfe/expool/journal.rb', line 202

def << (event)
    @events << event
end

#flushObject



211
212
213
214
215
216
217
218
# File 'lib/openwfe/expool/journal.rb', line 211

def flush
    File.open(@path, "a+") do |f|
        @events.each do |e|
            f.puts e
        end
    end
    @events.clear
end

#sizeObject Also known as: length



206
207
208
# File 'lib/openwfe/expool/journal.rb', line 206

def size
    @events.size
end