ruby_event_store 0.39.0 → 0.40.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_event_store.rb +24 -6
- data/lib/ruby_event_store/broker.rb +43 -0
- data/lib/ruby_event_store/client.rb +3 -3
- data/lib/ruby_event_store/dispatcher.rb +18 -0
- data/lib/ruby_event_store/errors.rb +13 -12
- data/lib/ruby_event_store/event.rb +1 -0
- data/lib/ruby_event_store/mappers.rb +10 -0
- data/lib/ruby_event_store/mappers/default.rb +8 -24
- data/lib/ruby_event_store/mappers/encryption_key.rb +72 -0
- data/lib/ruby_event_store/mappers/encryption_mapper.rb +8 -239
- data/lib/ruby_event_store/mappers/forgotten_data.rb +28 -0
- data/lib/ruby_event_store/mappers/in_memory_encryption_key_repository.rb +32 -0
- data/lib/ruby_event_store/mappers/null_mapper.rb +2 -18
- data/lib/ruby_event_store/mappers/pipeline.rb +29 -0
- data/lib/ruby_event_store/mappers/pipeline_mapper.rb +20 -0
- data/lib/ruby_event_store/mappers/protobuf.rb +9 -47
- data/lib/ruby_event_store/mappers/transformation/domain_event.rb +24 -0
- data/lib/ruby_event_store/mappers/transformation/encryption.rb +125 -0
- data/lib/ruby_event_store/mappers/transformation/event_class_remapper.rb +22 -0
- data/lib/ruby_event_store/mappers/transformation/item.rb +55 -0
- data/lib/ruby_event_store/mappers/transformation/proto_event.rb +15 -0
- data/lib/ruby_event_store/mappers/transformation/protobuf_encoder.rb +28 -0
- data/lib/ruby_event_store/mappers/transformation/protobuf_nested_struct_metadata.rb +29 -0
- data/lib/ruby_event_store/mappers/transformation/serialization.rb +32 -0
- data/lib/ruby_event_store/mappers/transformation/serialized_record.rb +25 -0
- data/lib/ruby_event_store/mappers/transformation/stringify_metadata_keys.rb +22 -0
- data/lib/ruby_event_store/mappers/transformation/symbolize_metadata_keys.rb +22 -0
- data/lib/ruby_event_store/pub_sub.rb +21 -0
- data/lib/ruby_event_store/spec/broker_lint.rb +3 -3
- data/lib/ruby_event_store/spec/dispatcher_lint.rb +2 -2
- data/lib/ruby_event_store/subscriptions.rb +108 -0
- data/lib/ruby_event_store/version.rb +1 -1
- metadata +24 -6
- data/lib/ruby_event_store/pub_sub/broker.rb +0 -45
- data/lib/ruby_event_store/pub_sub/dispatcher.rb +0 -20
- data/lib/ruby_event_store/pub_sub/subscriptions.rb +0 -110
@@ -1,20 +0,0 @@
|
|
1
|
-
module RubyEventStore
|
2
|
-
module PubSub
|
3
|
-
class Dispatcher
|
4
|
-
def call(subscriber, event, _)
|
5
|
-
subscriber = subscriber.new if Class === subscriber
|
6
|
-
subscriber.call(event)
|
7
|
-
end
|
8
|
-
|
9
|
-
def verify(subscriber)
|
10
|
-
begin
|
11
|
-
subscriber_instance = Class === subscriber ? subscriber.new : subscriber
|
12
|
-
rescue ArgumentError
|
13
|
-
false
|
14
|
-
else
|
15
|
-
subscriber_instance.respond_to?(:call)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
require 'concurrent'
|
2
|
-
|
3
|
-
module RubyEventStore
|
4
|
-
module PubSub
|
5
|
-
class Subscriptions
|
6
|
-
def initialize
|
7
|
-
@local = LocalSubscriptions.new
|
8
|
-
@global = GlobalSubscriptions.new
|
9
|
-
@thread = ThreadSubscriptions.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def add_subscription(subscriber, event_types)
|
13
|
-
local.add(subscriber, event_types)
|
14
|
-
end
|
15
|
-
|
16
|
-
def add_global_subscription(subscriber)
|
17
|
-
global.add(subscriber)
|
18
|
-
end
|
19
|
-
|
20
|
-
def add_thread_subscription(subscriber, event_types)
|
21
|
-
thread.local.add(subscriber, event_types)
|
22
|
-
end
|
23
|
-
|
24
|
-
def add_thread_global_subscription(subscriber)
|
25
|
-
thread.global.add(subscriber)
|
26
|
-
end
|
27
|
-
|
28
|
-
def all_for(event_type)
|
29
|
-
[local, global, thread].map{|r| r.all_for(event_type)}.reduce(&:+)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
attr_reader :local, :global, :thread
|
34
|
-
|
35
|
-
class ThreadSubscriptions
|
36
|
-
def initialize
|
37
|
-
@local = ThreadLocalSubscriptions.new
|
38
|
-
@global = ThreadGlobalSubscriptions.new
|
39
|
-
end
|
40
|
-
attr_reader :local, :global
|
41
|
-
|
42
|
-
def all_for(event_type)
|
43
|
-
[global, local].map{|r| r.all_for(event_type)}.reduce(&:+)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class LocalSubscriptions
|
48
|
-
def initialize
|
49
|
-
@subscriptions = Hash.new {|hsh, key| hsh[key] = [] }
|
50
|
-
end
|
51
|
-
|
52
|
-
def add(subscription, event_types)
|
53
|
-
event_types.each{ |type| @subscriptions[type.to_s] << subscription }
|
54
|
-
->() {event_types.each{ |type| @subscriptions.fetch(type.to_s).delete(subscription) } }
|
55
|
-
end
|
56
|
-
|
57
|
-
def all_for(event_type)
|
58
|
-
@subscriptions[event_type]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class GlobalSubscriptions
|
63
|
-
def initialize
|
64
|
-
@subscriptions = []
|
65
|
-
end
|
66
|
-
|
67
|
-
def add(subscription)
|
68
|
-
@subscriptions << subscription
|
69
|
-
->() { @subscriptions.delete(subscription) }
|
70
|
-
end
|
71
|
-
|
72
|
-
def all_for(_event_type)
|
73
|
-
@subscriptions
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
class ThreadLocalSubscriptions
|
78
|
-
def initialize
|
79
|
-
@subscriptions = Concurrent::ThreadLocalVar.new do
|
80
|
-
Hash.new {|hsh, key| hsh[key] = [] }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def add(subscription, event_types)
|
85
|
-
event_types.each{ |type| @subscriptions.value[type.to_s] << subscription }
|
86
|
-
->() {event_types.each{ |type| @subscriptions.value.fetch(type.to_s).delete(subscription) } }
|
87
|
-
end
|
88
|
-
|
89
|
-
def all_for(event_type)
|
90
|
-
@subscriptions.value[event_type]
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
class ThreadGlobalSubscriptions
|
95
|
-
def initialize
|
96
|
-
@subscriptions = Concurrent::ThreadLocalVar.new([])
|
97
|
-
end
|
98
|
-
|
99
|
-
def add(subscription)
|
100
|
-
@subscriptions.value += [subscription]
|
101
|
-
->() { @subscriptions.value -= [subscription] }
|
102
|
-
end
|
103
|
-
|
104
|
-
def all_for(_event_type)
|
105
|
-
@subscriptions.value
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|