Class: RailsEventStore::Client

Inherits:
RubyEventStore::Client
  • Object
show all
Defined in:
lib/rails_event_store/client.rb

Direct Known Subclasses

JSONClient

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mapper: RubyEventStore::Mappers::BatchMapper.new, repository: RubyEventStore::ActiveRecord::EventRepository.new(serializer: RubyEventStore::Serializers::YAML), subscriptions: nil, dispatcher: nil, message_broker: nil, clock: default_clock, correlation_id_generator: default_correlation_id_generator, request_metadata: default_request_metadata) ⇒ Client



7
8
9
10
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rails_event_store/client.rb', line 7

def initialize(
  mapper: RubyEventStore::Mappers::BatchMapper.new,
  repository: RubyEventStore::ActiveRecord::EventRepository.new(serializer: RubyEventStore::Serializers::YAML),
  subscriptions: nil,
  dispatcher: nil,
  message_broker: nil,
  clock: default_clock,
  correlation_id_generator: default_correlation_id_generator,
  request_metadata: 
)
  super(
    repository: RubyEventStore::InstrumentedRepository.new(repository, ActiveSupport::Notifications),
    mapper:
      (
        if batch_mapper?(mapper)
          RubyEventStore::Mappers::InstrumentedBatchMapper.new(mapper, ActiveSupport::Notifications)
        else
          RubyEventStore::Mappers::InstrumentedMapper.new(mapper, ActiveSupport::Notifications)
        end
      ),
    subscriptions: nil,
    clock: clock,
    correlation_id_generator: correlation_id_generator,
    dispatcher: nil,
    message_broker:
      RubyEventStore::InstrumentedBroker.new(
        message_broker ||
          RubyEventStore::Broker.new(
            subscriptions:
              RubyEventStore::InstrumentedSubscriptions.new(
                subscriptions || RubyEventStore::Subscriptions.new,
                ActiveSupport::Notifications,
              ),
            dispatcher:
              RubyEventStore::InstrumentedDispatcher.new(
                dispatcher ||
                  RubyEventStore::ComposedDispatcher.new(
                    RailsEventStore::AfterCommitAsyncDispatcher.new(
                      scheduler: ActiveJobScheduler.new(serializer: RubyEventStore::Serializers::YAML),
                    ),
                    RubyEventStore::Dispatcher.new,
                  ),
                ActiveSupport::Notifications,
              ),
          ),
        ActiveSupport::Notifications,
      ),
  )
   = 

  if (subscriptions || dispatcher)
    warn "      Passing subscriptions and dispatcher to \#{self.class} has been deprecated.\n\n      Pass it using message_broker argument. For example:\n\n      event_store = \#{self.class}.new(\n        message_broker: RubyEventStore::Broker.new(\n          subscriptions: RubyEventStore::Subscriptions.new,\n          dispatcher: RubyEventStore::ComposedDispatcher.new(\n            RailsEventStore::AfterCommitAsyncDispatcher.new(\n              scheduler: RailsEventStore::ActiveJobScheduler.new(serializer: RubyEventStore::Serializers::YAML)\n            ),\n            RubyEventStore::Dispatcher.new\n          )\n        )\n      )\n    EOW\n\n    warn <<~EOW if (message_broker)\n\n        Because message_broker has been provided,\n        arguments passed by subscriptions or dispatcher will be ignored.\n      EOW\n  end\nend\n"

Instance Attribute Details

#request_metadataObject (readonly)

Returns the value of attribute request_metadata.



5
6
7
# File 'lib/rails_event_store/client.rb', line 5

def 
  
end

Instance Method Details

#with_request_metadata(env, &block) ⇒ Object



84
85
86
# File 'lib/rails_event_store/client.rb', line 84

def (env, &block)
  (.call(env)) { block.call }
end