Skip to content

Commit

Permalink
added yard doc for methods
Browse files Browse the repository at this point in the history
  • Loading branch information
raghuramg committed Jan 2, 2025
1 parent c946b54 commit a9a6dea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/event_source/protocols/amqp/bunny_queue_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ def on_receive_message(
subscriber = nil
end

# Decodes the given payload based on the `contentEncoding` specified in the AsyncAPI *_subscribe.yml message bindings.
#
# For example, if `contentEncoding` is set to `application/zlib`, the payload will be decompressed using zlib.
# If no `contentEncoding` is provided, the payload will be returned unchanged.
#
# @param payload [String] The payload to be decoded.
# @return [String] The decoded payload, or the original payload if no encoding is specified.
# @raise [EventSource::Error::PayloadDecodeError] if the decoding process fails.
def decode_payload(payload)
async_api_subscribe_operation = @async_api_channel_item.subscribe
return payload unless async_api_subscribe_operation.message
Expand Down
12 changes: 12 additions & 0 deletions lib/event_source/publish_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ def call(payload, options = {})
)
end

# Encodes the given payload based on the `contentEncoding` specified in the AsyncAPI *_publish.yml message bindings.
#
# For example, if `contentEncoding` is set to `application/zlib`, the payload will be compressed using zlib.
# If no `contentEncoding` is provided, the payload will be returned as-is without modification.
#
# Note:
# - Encoding is not needed for the HTTP protocol, as encoding is handled at the server level.
# - For other protocols like AMQP, encoding is supported to ensure proper message transmission.
#
# @param payload [String, Hash] The payload to be encoded.
# @return [String] The encoded payload, or the original payload if no encoding is specified.
# @raise [EventSource::Error::PayloadEncodeError] if the encoding process fails.
def encode_payload(payload)
return payload unless @async_api_publish_operation.message

Expand Down

0 comments on commit a9a6dea

Please sign in to comment.