Skip to content

Commit

Permalink
update bunny queue proxy and remove payload_codec
Browse files Browse the repository at this point in the history
  • Loading branch information
raghuramg committed Dec 30, 2024
1 parent 598a7a7 commit cf29516
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 227 deletions.
1 change: 0 additions & 1 deletion lib/event_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
require 'event_source/event'
require 'event_source/subscriber'
require 'event_source/operations/codec64'
require 'event_source/operations/payload_codec'
require 'event_source/operations/mime_encode'
require 'event_source/operations/mime_decode'
require 'event_source/operations/create_message'
Expand Down
80 changes: 0 additions & 80 deletions lib/event_source/operations/payload_codec.rb

This file was deleted.

8 changes: 7 additions & 1 deletion lib/event_source/protocols/amqp/bunny_queue_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class BunnyQueueProxy
# @return [Bunny::Queue]
def initialize(channel_proxy, async_api_channel_item)
@channel_proxy = channel_proxy
@async_api_channel_item = async_api_channel_item
bindings = async_api_channel_item.bindings
@consumers = []

Expand Down Expand Up @@ -151,8 +152,13 @@ def on_receive_message(
end

def decompress_payload_if_binary(payload)
output = EventSource::Operations::PayloadCodec.new(payload: payload).decompress_if_binary
async_api_subscribe_operation = @async_api_channel_item.subscribe
return payload unless async_api_subscribe_operation.message

encoding = async_api_subscribe_operation.message['bindings'].first[1]['contentEncoding']
return payload unless encoding

output = EventSource::Operations::MimeDecode.new.call(encoding, payload)
if output.success?
output.value!
else
Expand Down
5 changes: 2 additions & 3 deletions lib/event_source/publish_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ def compress_payload_if_required(payload)

message_bindings = @async_api_publish_operation.message['bindings']
encoding = message_bindings.first[1]['contentEncoding'] if message_bindings
return payload if encoding.nil? || encoding != 'zlib'

output = EventSource::Operations::PayloadCodec.new(payload: payload).compress
return payload if encoding.nil?

output = EventSource::Operations::MimeEncode.new.call(encoding, payload)
if output.success?
output.value!
else
Expand Down
142 changes: 0 additions & 142 deletions spec/event_source/operations/payload_codec_spec.rb

This file was deleted.

0 comments on commit cf29516

Please sign in to comment.