Sha256: 80792723bc149b63de43141abf2ca94b9ca2b49a153d2eccf5d0688bb51f93c5
Contents?: true
Size: 1.3 KB
Versions: 25
Compression:
Stored size: 1.3 KB
Contents
module Messaging module Adapters class Postgres class Stream # @return [String] the name of the stream attr_reader :name # @return [String] the stream category attr_reader :category # @return [String] the stream id attr_reader :id # Should not be used directly. # Use {Messaging.stream} or {Store#stream} # @api private # @see Messaging.stream # @see Store.stream def initialize(name) @name = name @category, @id = name.split('$') end # Access to all messages in the stream sorted by stream_position # @return [ActiveRecord::Relation] def messages SerializedMessage.where(stream_category: category, stream_id: id).order(:stream_position) end # The current position of the last message in the stream # @return [-1] if the stream is empty -1 will be returned # @return [Integer] the stream position of the last message in the stream def current_position messages.maximum(:stream_position) || -1 end def to_s name end def inspect info = "current_position: #{current_position}" "#<Stream:#{name}> #{info}>" end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems