Skip to content

Commit

Permalink
Merge branch 'main' into release/1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
owenpearson committed Apr 5, 2022
2 parents 64fd0cf + 6d87a7f commit 5367511
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ This release is all about channel options. Here is the full [changelog](https://

* The `ChannelOptions` class now supports `:params`, `:modes` and `:cipher` as options. Previously only `:cipher` was available

* The client `:idempotent_rest_publishing` option is `true` by default. Previously `:idempotent_rest_publishing` was `false` by default.

### Breaking Changes

* Changing channel options with `Channels#get` is now deprecated in favor of explicit options change
Expand Down
5 changes: 4 additions & 1 deletion lib/ably/rest/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,13 @@ def initialize(options)
@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 (@idempotent_rest_publishing = options.delete(:idempotent_rest_publishing)).nil?
@idempotent_rest_publishing = Ably::PROTOCOL_VERSION.to_f > 1.1
end

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
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/rest/channel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
include Ably::Modules::Conversions

vary_by_protocol do
let(:default_options) { { key: api_key, environment: environment, protocol: protocol, max_frame_size: max_frame_size, max_message_size: max_message_size } }
let(:default_options) { { key: api_key, environment: environment, protocol: protocol, max_frame_size: max_frame_size, max_message_size: max_message_size, idempotent_rest_publishing: false } }
let(:client_options) { default_options }
let(:client) do
Ably::Rest::Client.new(client_options)
Expand Down
13 changes: 10 additions & 3 deletions spec/acceptance/rest/message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,20 @@
end
end

specify 'idempotent publishing is disabled by default with 1.1 (#TO3n)' do
specify 'idempotent publishing is disabled by default with <= 1.1 (#TO3n)' do
stub_const 'Ably::PROTOCOL_VERSION', '1.0'
client = Ably::Rest::Client.new(key: api_key, protocol: protocol)
expect(client.idempotent_rest_publishing).to be_falsey
stub_const 'Ably::PROTOCOL_VERSION', '1.1'
client = Ably::Rest::Client.new(key: api_key, protocol: protocol)
expect(client.idempotent_rest_publishing).to be_falsey
end

specify 'idempotent publishing is enabled by default with 1.2 (#TO3n)' do
stub_const 'Ably::VERSION', '1.2.0'
specify 'idempotent publishing is enabled by default with >= 1.2 (#TO3n)' do
stub_const 'Ably::PROTOCOL_VERSION', '1.2'
client = Ably::Rest::Client.new(key: api_key, protocol: protocol)
expect(client.idempotent_rest_publishing).to be_truthy
stub_const 'Ably::PROTOCOL_VERSION', '1.3'
client = Ably::Rest::Client.new(key: api_key, protocol: protocol)
expect(client.idempotent_rest_publishing).to be_truthy
end
Expand Down

0 comments on commit 5367511

Please sign in to comment.