Class: EventStoreClient::GRPC::Commands::PersistentSubscriptions::Read

Inherits:
Command
  • Object
show all
Defined in:
lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/read.rb

Instance Method Summary collapse

Methods inherited from Command

inherited, #metadata

Methods included from Configuration

#config

Instance Method Details

#call(stream, group, options: {}) ⇒ Dry::Monads::Result::Success, Dry::Monads::Result::Failure

Read given persistent subscription

Parameters:

  • name (String)

    of the stream to subscribe

  • name (String)

    of the subscription group

  • options (Hash) (defaults to: {})
    • additional settings to be set on subscription.

    Refer to SettingsSchema for detailed attributes allowed

Returns:

  • (Dry::Monads::Result::Success, Dry::Monads::Result::Failure)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/read.rb', line 25

def call(stream, group, options: {})
  count = options[:count].to_i
  opts =
    {
      stream_identifier: {
        streamName: stream
      },
      buffer_size: count,
      group_name: group,
      uuid_option: {
        structured: {}
      }
    }

  requests = [request.new(options: opts)] # please notice that it's an array. Should be?

  skip_decryption = options[:skip_decryption] || false
  service.read(requests, metadata: ).each do |res|
    next if res.subscription_confirmation
    yield deserialize_event(res.event.event, skip_decryption: skip_decryption) if block_given?
  end
  Success()
end