Class: Consumer::Postgres::PositionStore
- Inherits:
-
Object
- Object
- Consumer::Postgres::PositionStore
show all
- Includes:
- Consumer::PositionStore, Initializer
- Defined in:
- lib/consumer/postgres/position_store.rb,
lib/consumer/postgres/position_store/recorded.rb,
lib/consumer/postgres/position_store/stream_name.rb
Defined Under Namespace
Modules: StreamName
Classes: Recorded
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.build(stream_name, session: nil, consumer_identifier: nil) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/consumer/postgres/position_store.rb', line 13
def self.build(stream_name, session: nil, consumer_identifier: nil)
position_stream_name = StreamName.position_stream_name(stream_name, consumer_identifier: consumer_identifier)
instance = new(position_stream_name)
MessageStore::Postgres::Session.configure(instance, session: session)
instance.configure
instance
end
|
Instance Method Details
22
23
24
25
26
27
28
29
30
|
# File 'lib/consumer/postgres/position_store.rb', line 22
def configure
MessageStore::Postgres::Get::Stream::Last.configure(
self,
session: session,
attr_name: :read
)
Messaging::Postgres::Write.configure(self, session: session)
end
|
#get ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/consumer/postgres/position_store.rb', line 36
def get
message_data = read.(stream_name)
return nil if message_data.nil?
message = Messaging::Message::Import.(message_data, Recorded)
message.position
end
|
#location ⇒ Object
32
33
34
|
# File 'lib/consumer/postgres/position_store.rb', line 32
def location
stream_name
end
|
#put(position) ⇒ Object
46
47
48
49
50
51
|
# File 'lib/consumer/postgres/position_store.rb', line 46
def put(position)
message = Recorded.new
message.position = position
write.(message, stream_name)
end
|