11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/event_store_client/adapters/http/commands/persistent_subscriptions/read.rb', line 11
def call(stream_name, subscription_name, options: {})
count = options[:count] || 20
long_poll = options[:long_poll].to_i
= long_poll.positive? ? { 'ES-LongPoll' => long_poll.to_s } : {}
['Content-Type'] = 'application/vnd.eventstore.competingatom+json'
['Accept'] = 'application/vnd.eventstore.competingatom+json'
['ES-ResolveLinktos'] = (options[:resolve_links] || true).to_s
response = connection.call(
:get,
"/subscriptions/#{stream_name}/#{subscription_name}/#{count}",
headers:
)
return { events: [] } if response.body.nil? || response.body.empty?
body = JSON.parse(response.body)
ack_info = body['links'].find { |link| link['relation'] == 'ackAll' }
return { events: [] } unless ack_info
skip_decryption = options[:skip_decryption] || false
body['entries'].map do |entry|
yield deserialize_event(entry, skip_decryption: skip_decryption)
end
Ack.new(connection).call(ack_info['uri'])
Success()
end
|