Skip to content

Commit 932d2c6

Browse files
committed
Added compress options support for publishers
1 parent 8f93045 commit 932d2c6

29 files changed

Lines changed: 166 additions & 19 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [6.11.0] - 2026-03-25
5+
### Added
6+
- Ability to specify option for compression when publish data
7+
48
## [6.10.0] - 2025-11-21
59
### Added
610
- Add on_first_sync callback

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ gem "bundler"
1919
gem "ostruct"
2020
gem "pry"
2121
gem "rake"
22+
23+
gem "rabbit_messaging", git: "git@github.com:umbrellio/rabbit_messaging.git", branch: "compression-for-publisher-and-reciver"

Gemfile.lock

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
GIT
2+
remote: git@github.com:umbrellio/rabbit_messaging.git
3+
revision: 2a31c6878f012fd3a31f538a9d1ac2d0670a2e50
4+
branch: compression-for-publisher-and-reciver
5+
specs:
6+
rabbit_messaging (1.8.0)
7+
bunny (~> 2.0)
8+
kicks
9+
msgpack
10+
zlib
11+
112
PATH
213
remote: .
314
specs:
4-
table_sync (6.10.0)
15+
table_sync (6.11.0)
516
memery
6-
rabbit_messaging (>= 1.7.0)
17+
rabbit_messaging (>= 1.8.0)
718
rails
819
self_data
920

@@ -136,6 +147,7 @@ GEM
136147
mini_mime (1.1.5)
137148
mini_portile2 (2.8.9)
138149
minitest (5.25.5)
150+
msgpack (1.8.0)
139151
net-imap (0.5.12)
140152
date
141153
net-protocol
@@ -181,9 +193,6 @@ GEM
181193
psych (5.2.6)
182194
date
183195
stringio
184-
rabbit_messaging (1.7.0)
185-
bunny (~> 2.0)
186-
kicks
187196
racc (1.8.1)
188197
rack (3.1.15)
189198
rack-session (2.1.1)
@@ -326,6 +335,7 @@ GEM
326335
websocket-extensions (>= 0.1.0)
327336
websocket-extensions (0.1.5)
328337
zeitwerk (2.6.18)
338+
zlib (3.2.3)
329339

330340
PLATFORMS
331341
aarch64-linux-gnu
@@ -345,6 +355,7 @@ DEPENDENCIES
345355
ostruct
346356
pg
347357
pry
358+
rabbit_messaging!
348359
rake
349360
rspec
350361
rubocop-config-umbrellio

lib/table_sync.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def sync(object_class, **options)
5252
if_condition: options[:if],
5353
unless_condition: options[:unless],
5454
debounce_time: options[:debounce_time],
55+
compress: options.fetch(:compress, false)
5556
).register_callbacks
5657
end
5758

lib/table_sync/instrument_adapter/active_support.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ module TableSync::InstrumentAdapter
44
module ActiveSupport
55
module_function
66

7-
def notify(table:, schema:, event:, direction:, count: 1)
7+
def notify(table:, schema:, event:, direction:, count: 1, compress: false)
88
::ActiveSupport::Notifications.instrument "tablesync.#{direction}.#{event}",
99
count:,
1010
table: table.to_s,
1111
schema: schema.to_s,
1212
event:,
13-
direction:
13+
direction:,
14+
compress:
1415
end
1516
end
1617
end

lib/table_sync/publishing/batch.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ class TableSync::Publishing::Batch
66
:custom_version,
77
:routing_key,
88
:headers,
9-
:event
9+
:event,
10+
:compress
1011

1112
def initialize(attrs = {})
1213
attrs = attrs.with_indifferent_access
@@ -17,6 +18,7 @@ def initialize(attrs = {})
1718
self.routing_key = attrs[:routing_key]
1819
self.headers = attrs[:headers]
1920
self.event = attrs.fetch(:event, :update).to_sym
21+
self.compress = attrs.fetch(:compress, false)
2022

2123
validate_required_attributes!
2224
end
@@ -55,6 +57,7 @@ def attributes
5557
routing_key: routing_key,
5658
headers: headers,
5759
event: event,
60+
compress: compress,
5861
}
5962
end
6063

lib/table_sync/publishing/message/base.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ class Base
55
attr_accessor :custom_version,
66
:object_class,
77
:original_attributes,
8-
:event
8+
:event,
9+
:compress
910

1011
attr_reader :objects
1112

@@ -14,6 +15,7 @@ def initialize(params = {})
1415
self.object_class = params[:object_class]
1516
self.original_attributes = params[:original_attributes]
1617
self.event = params[:event].to_sym
18+
self.compress = params.fetch(:compress, false)
1719

1820
@objects = find_or_init_objects
1921

@@ -65,6 +67,7 @@ def notify!
6567
table: model_naming.table,
6668
schema: model_naming.schema,
6769
event:,
70+
compress:,
6871
direction: :publish,
6972
count: objects.count,
7073
)

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: }.compact,
16+
{ object_class:, headers:, routing_key:, compress: }.compact,
1717
).construct
1818
end
1919
end

lib/table_sync/publishing/message/raw.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ class Raw
99
:routing_key,
1010
:headers,
1111
:custom_version,
12-
:event
12+
:event,
13+
:compress
1314

1415
def initialize(params = {})
1516
self.model_name = params[:model_name]
@@ -20,6 +21,7 @@ def initialize(params = {})
2021
self.headers = params[:headers]
2122
self.custom_version = params[:custom_version]
2223
self.event = params[:event]
24+
self.compress = params.fetch(:compress, false)
2325
end
2426

2527
def publish
@@ -35,6 +37,7 @@ def notify!
3537
table: table_name,
3638
schema: schema_name,
3739
event:,
40+
compress: compress,
3841
count: original_attributes.count,
3942
direction: :publish,
4043
)
@@ -57,7 +60,7 @@ def data
5760

5861
def params
5962
TableSync::Publishing::Params::Raw.new(
60-
{ model_name:, headers:, routing_key: }.compact,
63+
{ model_name:, headers:, routing_key:, compress: }.compact,
6164
).construct
6265
end
6366
end

lib/table_sync/publishing/message/single.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def object
77
end
88

99
def params
10-
TableSync::Publishing::Params::Single.new(object:).construct
10+
TableSync::Publishing::Params::Single.new(object:, compress:).construct
1111
end
1212
end
1313
end

0 commit comments

Comments
 (0)