Class: EventStoreClient::GRPC::Options::Streams::WriteOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/event_store_client/adapters/grpc/options/streams/write_options.rb

Instance Method Summary collapse

Constructor Details

#initialize(stream_name, options) ⇒ WriteOptions

Returns a new instance of WriteOptions.

Parameters:

  • stream_name (String)
  • options (Hash)
  • [Integer] (Hash)

    a customizable set of options

  • [Symbol] (Hash)

    a customizable set of options



15
16
17
18
# File 'lib/event_store_client/adapters/grpc/options/streams/write_options.rb', line 15

def initialize(stream_name, options)
  @stream_name = stream_name
  @options = options
end

Instance Method Details

#request_optionsHash

Returns see event_store.client.streams.AppendReq.Options for available options.

Returns:

  • (Hash)

    see event_store.client.streams.AppendReq.Options for available options



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/event_store_client/adapters/grpc/options/streams/write_options.rb', line 21

def request_options
  revision_opt =
    case options[:expected_revision]
    when :any, :no_stream, :stream_exists
      { options[:expected_revision] => EventStore::Client::Empty.new }
    when Integer
      { revision: options[:expected_revision] }
    else
      { any: EventStore::Client::Empty.new }
    end
  revision_opt.merge(stream_identifier: { stream_name: stream_name })
end