lib/ably/rest/client.rb in ably-1.1.7 vs lib/ably/rest/client.rb in ably-1.1.8
- old
+ new
@@ -23,11 +23,12 @@
extend Forwardable
# Default Ably domain for REST
DOMAIN = 'rest.ably.io'
- MAX_FRAME_SIZE = 524288
+ MAX_MESSAGE_SIZE = 65536 # See spec TO3l8
+ MAX_FRAME_SIZE = 524288 # See spec TO3l8
# Configuration for HTTP timeouts and HTTP request reattempts to fallback hosts
HTTP_DEFAULTS = {
open_timeout: 4,
request_timeout: 10,
@@ -116,10 +117,18 @@
# automatically retried will not result in duplicate messages being published to the Ably platform.
# Note: This is a beta unsupported feature!
# @return [Boolean]
attr_reader :idempotent_rest_publishing
+ # Max message size (TO2, TO3l8) by default (65536 bytes) 64KiB
+ # @return [Integer]
+ attr_reader :max_message_size
+
+ # Max frame size (TO2, TO3l8) by default (524288 bytes) 512KiB
+ # @return [Integer]
+ attr_reader :max_frame_size
+
# Creates a {Ably::Rest::Client Rest Client} and configures the {Ably::Auth} object for the connection.
#
# @param [Hash,String] options an options Hash used to configure the client and the authentication, or String with an API key or Token ID
# @option options [Boolean] :tls (true) When false, TLS is disabled. Please note Basic Auth is disallowed without TLS as secrets cannot be transmitted over unsecured connections.
# @option options [String] :key API key comprising the key name and key secret in a single string
@@ -150,10 +159,12 @@
# @option options [Array<String>] :fallback_hosts When an array of fallback hosts are provided, these fallback hosts are always used if a request fails to the primary endpoint. If an empty array is provided, the fallback host functionality is disabled
# @option options [Integer] :fallback_retry_timeout (600 seconds) amount of time in seconds a REST client will continue to use a working fallback host when the primary fallback host has previously failed
#
# @option options [Boolean] :add_request_ids (false) When true, adds a unique request_id to each request sent to Ably servers. This is handy when reporting issues, because you can refer to a specific request.
# @option options [Boolean] :idempotent_rest_publishing (false if ver < 1.2) When true, idempotent publishing is enabled for all messages published via REST
+ # @option options [Integer] :max_message_size (65536 bytes) Maximum size of all messages when publishing via REST publish()
+ # @option options [Integer] :max_frame_size (524288 bytes) Maximum size of frame
#
# @return [Ably::Rest::Client]
#
# @example
# # create a new client authenticating with basic auth
@@ -187,12 +198,13 @@
@custom_port = options.delete(:port)
@custom_tls_port = options.delete(:tls_port)
@add_request_ids = options.delete(:add_request_ids)
@log_retries_as_info = options.delete(:log_retries_as_info)
@idempotent_rest_publishing = options.delete(:idempotent_rest_publishing) || Ably.major_minor_version_numeric > 1.1
+ @max_message_size = options.delete(:max_message_size) || MAX_MESSAGE_SIZE
+ @max_frame_size = options.delete(:max_frame_size) || MAX_FRAME_SIZE
-
if options[:fallback_hosts_use_default] && options[:fallback_hosts]
raise ArgumentError, "fallback_hosts_use_default cannot be set to try when fallback_hosts is also provided"
end
@fallback_hosts = case
when options.delete(:fallback_hosts_use_default)
@@ -363,11 +375,11 @@
when :get, :delete
reauthorize_on_authorization_failure do
send_request(method, path, params, headers: headers)
end
when :post, :patch, :put
- if body.to_json.bytesize > MAX_FRAME_SIZE
- raise Ably::Exceptions::MaxFrameSizeExceeded.new("Maximum frame size exceeded #{MAX_FRAME_SIZE} bytes.")
+ if body.to_json.bytesize > max_frame_size
+ raise Ably::Exceptions::MaxFrameSizeExceeded.new("Maximum frame size exceeded #{max_frame_size} bytes.")
end
path_with_params = Addressable::URI.new
path_with_params.query_values = params || {}
query = path_with_params.query
reauthorize_on_authorization_failure do