class RailsEventStore::Client
Attributes
request_metadata[R]
Public Class Methods
new( mapper: RubyEventStore::Mappers::Default.new, repository: RubyEventStore::ActiveRecord::EventRepository.new(serializer: RubyEventStore::Serializers::YAML), subscriptions: RubyEventStore::Subscriptions.new, dispatcher: RubyEventStore::ComposedDispatcher.new( RailsEventStore::AfterCommitAsyncDispatcher.new( scheduler: ActiveJobScheduler.new(serializer: RubyEventStore::Serializers::YAML) ), RubyEventStore::Dispatcher.new ), clock: default_clock, correlation_id_generator: default_correlation_id_generator, request_metadata: default_request_metadata )
click to toggle source
Calls superclass method
# File lib/rails_event_store/client.rb, line 7 def initialize( mapper: RubyEventStore::Mappers::Default.new, repository: RubyEventStore::ActiveRecord::EventRepository.new(serializer: RubyEventStore::Serializers::YAML), subscriptions: RubyEventStore::Subscriptions.new, dispatcher: RubyEventStore::ComposedDispatcher.new( RailsEventStore::AfterCommitAsyncDispatcher.new( scheduler: ActiveJobScheduler.new(serializer: RubyEventStore::Serializers::YAML) ), RubyEventStore::Dispatcher.new ), clock: default_clock, correlation_id_generator: default_correlation_id_generator, request_metadata: default_request_metadata ) super( repository: RubyEventStore::InstrumentedRepository.new(repository, ActiveSupport::Notifications), mapper: RubyEventStore::Mappers::InstrumentedMapper.new(mapper, ActiveSupport::Notifications), subscriptions: RubyEventStore::InstrumentedSubscriptions.new(subscriptions, ActiveSupport::Notifications), clock: clock, correlation_id_generator: correlation_id_generator, dispatcher: RubyEventStore::InstrumentedDispatcher.new(dispatcher, ActiveSupport::Notifications) ) @request_metadata = request_metadata end
Public Instance Methods
with_request_metadata(env, &block)
click to toggle source
# File lib/rails_event_store/client.rb, line 32 def with_request_metadata(env, &block) with_metadata(request_metadata.call(env)) { block.call } end
Private Instance Methods
default_request_metadata()
click to toggle source
# File lib/rails_event_store/client.rb, line 38 def default_request_metadata ->(env) do request = ActionDispatch::Request.new(env) { remote_ip: request.remote_ip, request_id: request.uuid } end end