Class: Messaging::Adapters::Postgres::Stream
- Inherits:
-
Object
- Object
- Messaging::Adapters::Postgres::Stream
- Defined in:
- lib/messaging/adapters/postgres/stream.rb
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the stream.
Instance Method Summary collapse
-
#current_position ⇒ -1, Integer
The current position of the last message in the stream.
-
#initialize(name) ⇒ Stream
constructor
private
Should not be used directly.
- #inspect ⇒ Object
-
#messages ⇒ ActiveRecord::Relation
Access to all messages in the stream sorted by stream_position.
Constructor Details
#initialize(name) ⇒ Stream
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Should not be used directly. Use Messaging.stream or Messaging::Adapters::Postgres::Store#stream
13 14 15 |
# File 'lib/messaging/adapters/postgres/stream.rb', line 13 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of the stream.
6 7 8 |
# File 'lib/messaging/adapters/postgres/stream.rb', line 6 def name @name end |
Instance Method Details
#current_position ⇒ -1, Integer
The current position of the last message in the stream
26 27 28 |
# File 'lib/messaging/adapters/postgres/stream.rb', line 26 def current_position .maximum(:stream_position) || -1 end |
#inspect ⇒ Object
30 31 32 33 |
# File 'lib/messaging/adapters/postgres/stream.rb', line 30 def inspect info = "current_position: #{current_position}" "#<Stream:#{name}> #{info}>" end |
#messages ⇒ ActiveRecord::Relation
Access to all messages in the stream sorted by stream_position
19 20 21 |
# File 'lib/messaging/adapters/postgres/stream.rb', line 19 def SerializedMessage.where(stream: name).order(:stream_position) end |