Sha256: fde7a315ef07ef464dfffb6c934436d165db613fddd5116ce2af0968a9a5a1a0

Contents?: true

Size: 561 Bytes

Versions: 1

Compression:

Stored size: 561 Bytes

Contents

module Aggro
  class FileStore
    # Private: Serializes events to an IO object.
    class Writer
      def initialize(data_io, index_io)
        @data_io = data_io
        @index_io = index_io
      end

      def write(events)
        events.each do |event|
          @data_io.write Marshal.dump EventSerializer.serialize(event)
          write_to_index @data_io.pos
        end

        @data_io.flush
        @index_io.flush
      end

      private

      def write_to_index(offset)
        @index_io.write Marshal.dump(offset)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aggro-0.0.4 lib/aggro/file_store/writer.rb