Skip to content

Commit 26d9df4

Browse files
committed
f
1 parent dc962c1 commit 26d9df4

21 files changed

Lines changed: 64 additions & 67 deletions

File tree

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GIT
22
remote: https://github.com/umbrellio/rabbit_messaging.git
3-
revision: a7c85902a8655745525e3f378e58f816ec4ab9c0
3+
revision: 975cdf925ab5102c0234bfcf2732dbaaa49a0ed3
44
branch: compression-for-publisher-and-reciver
55
specs:
66
rabbit_messaging (1.8.0)
@@ -92,7 +92,7 @@ GEM
9292
minitest (>= 5.1)
9393
securerandom (>= 0.3)
9494
tzinfo (~> 2.0, >= 2.0.5)
95-
amq-protocol (2.5.1)
95+
amq-protocol (2.7.0)
9696
ast (2.4.3)
9797
base64 (0.3.0)
9898
benchmark (0.4.0)
@@ -123,8 +123,8 @@ GEM
123123
rdoc (>= 4.0.0)
124124
reline (>= 0.4.2)
125125
json (2.12.2)
126-
kicks (3.2.0)
127-
bunny (~> 2.19)
126+
kicks (3.3.0)
127+
bunny (~> 2.24)
128128
concurrent-ruby (~> 1.0)
129129
rake (>= 12.3, < 14.0)
130130
serverengine (~> 2.1)

lib/table_sync/publishing/batch.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def initialize(attrs = {})
1616
self.original_attributes = attrs[:original_attributes]
1717
self.custom_version = attrs[:custom_version]
1818
self.routing_key = attrs[:routing_key]
19-
self.headers = attrs[:headers]
19+
self.headers = attrs[:headers] || {}
2020
self.event = attrs.fetch(:event, :update).to_sym
2121
self.compress = attrs.fetch(:compress, false)
2222

@@ -55,9 +55,8 @@ def attributes
5555
original_attributes: original_attributes,
5656
custom_version: custom_version,
5757
routing_key: routing_key,
58-
headers: headers,
58+
headers: headers.merge(compress: compress),
5959
event: event,
60-
compress: compress,
6160
}
6261
end
6362

lib/table_sync/publishing/message/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize(params = {})
1515
self.object_class = params[:object_class]
1616
self.original_attributes = params[:original_attributes]
1717
self.event = params[:event].to_sym
18-
self.compress = params.fetch(:compress, false)
18+
self.compress = params.dig(:headers, :compress) || false
1919

2020
@objects = find_or_init_objects
2121

lib/table_sync/publishing/message/batch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def initialize(params = {})
1313

1414
def params
1515
TableSync::Publishing::Params::Batch.new(
16-
{ object_class:, headers:, routing_key:, compress: }.compact,
16+
{ object_class:, headers:, routing_key: }.compact,
1717
).construct
1818
end
1919
end

lib/table_sync/publishing/message/raw.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def data
6060

6161
def params
6262
TableSync::Publishing::Params::Raw.new(
63-
{ model_name:, headers:, routing_key:, compress: }.compact,
63+
{ model_name:, headers:, routing_key: }.compact,
6464
).construct
6565
end
6666
end

lib/table_sync/publishing/message/single.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22

33
module TableSync::Publishing::Message
44
class Single < Base
5+
attr_accessor :headers
6+
7+
def initialize(params = {})
8+
super
9+
10+
self.headers = params[:headers]
11+
end
12+
513
def object
614
objects.first
715
end
816

917
def params
10-
TableSync::Publishing::Params::Single.new(object:, compress:).construct
18+
TableSync::Publishing::Params::Single.new(object:, headers:).construct
1119
end
1220
end
1321
end

lib/table_sync/publishing/params/base.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ def construct
1313
routing_key:,
1414
headers:,
1515
exchange_name:,
16-
compress: compress,
1716
)
1817
end
1918

20-
attr_accessor :compress
21-
2219
private
2320

2421
def calculated_routing_key

lib/table_sync/publishing/params/batch.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def initialize(attrs = {})
1010
@exchange_name = attrs[:exchange_name]
1111
@routing_key = attrs[:routing_key]
1212
@headers = attrs[:headers]
13-
@compress = attrs.fetch(:compress, false)
1413
end
1514

1615
def exchange_name

lib/table_sync/publishing/params/single.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ module TableSync::Publishing::Params
44
class Single < Base
55
attr_reader :object, :routing_key, :headers
66

7-
def initialize(object:, compress: false)
7+
def initialize(object:, headers: {})
88
@object = object
99
@routing_key = calculated_routing_key
10-
@headers = calculated_headers
11-
@compress = compress
10+
@headers = headers.merge(calculated_headers || {})
1211
end
1312

1413
private

lib/table_sync/publishing/raw.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ def attributes
4747
original_attributes: original_attributes,
4848
custom_version: custom_version,
4949
routing_key: routing_key,
50-
headers: headers,
50+
headers: headers.merge(compress: compress),
5151
event: event,
52-
compress: compress,
5352
}
5453
end
5554
end

0 commit comments

Comments
 (0)