Class: Ably::Rest::Client
- Inherits:
-
Object
- Object
- Ably::Rest::Client
- Extended by:
- Forwardable
- Includes:
- Modules::Conversions, Modules::HttpHelpers
- Defined in:
- lib/submodules/ably-ruby/lib/ably/rest/client.rb
Overview
A client that offers a simple stateless API to interact directly with Ably’s REST API.
Constant Summary collapse
- DOMAIN =
Default Ably domain for REST
'rest.ably.io'
- MAX_MESSAGE_SIZE =
See spec TO3l8
65536
- MAX_FRAME_SIZE =
See spec TO3l8
524288
- HTTP_DEFAULTS =
Configuration for HTTP timeouts and HTTP request reattempts to fallback hosts
{ open_timeout: 4, request_timeout: 10, max_retry_duration: 15, max_retry_count: 3 }.freeze
- FALLBACK_RETRY_TIMEOUT =
10 * 60
- FARADAY_CLIENT_OR_SERVER_ERRORS =
Faraday 1.0 introduced new error types, however we want to support Faraday <1 too which only used Faraday::ClientError
if defined?(Faraday::ParsingError) [Faraday::ClientError, Faraday::ServerError, Faraday::ConnectionFailed, Faraday::SSLError, Faraday::ParsingError] else Faraday::ClientError end
Instance Attribute Summary collapse
-
#add_request_ids ⇒ Boolean
readonly
Whether the Client has to add a random identifier to the path of a request.
-
#agent ⇒ String
readonly
Client agent i.e.
-
#auth ⇒ Ably::Auth
readonly
An Auth object.
-
#channels ⇒ Aby::Rest::Channels
readonly
A Channels object.
-
#custom_host ⇒ String, Nil
readonly
The custom host that is being used if it was provided with the option
:rest_host
when the Client was created. -
#custom_port ⇒ Integer, Nil
readonly
The custom port for non-TLS requests if it was provided with the option
:port
when the Client was created. -
#custom_tls_port ⇒ Integer, Nil
readonly
The custom TLS port for TLS requests if it was provided with the option
:tls_port
when the Client was created. -
#encoders ⇒ Array<Ably::Models::MessageEncoder::Base>
readonly
private
The registered encoders that are used to encode and decode message payloads.
-
#endpoint ⇒ URI::Generic
readonly
Default Ably REST endpoint used for all requests.
-
#environment ⇒ String
readonly
Custom environment to use such as ‘sandbox’ when testing the client library against an alternate Ably environment.
-
#fallback_hosts ⇒ Object
readonly
The list of fallback hosts to be used by this client if empty or nil then fallback host functionality is disabled.
-
#http_defaults ⇒ Hash
readonly
The immutable configured HTTP defaults for this client.
-
#idempotent_rest_publishing ⇒ Boolean
readonly
True when idempotent publishing is enabled for all messages published via REST.
-
#log_level ⇒ Logger::Severity
readonly
Log level configured for this Client.
-
#log_retries_as_info ⇒ Boolean
readonly
private
Retries are logged by default to warn and error.
-
#logger ⇒ Logger
readonly
The Logger for this client.
-
#max_frame_size ⇒ Integer
readonly
Max frame size (TO2, TO3l8) by default (524288 bytes) 512KiB.
-
#max_message_size ⇒ Integer
readonly
Max message size (TO2, TO3l8) by default (65536 bytes) 64KiB.
-
#mime_type ⇒ String
readonly
Mime type used for HTTP requests.
-
#options ⇒ Hash
readonly
private
The additional options passed to this Client’s #initialize method not available as attributes of this class.
-
#protocol ⇒ Symbol
readonly
The protocol configured for this client, either binary ‘:msgpack` or text based `:json`.
-
#protocol_binary? ⇒ Boolean
readonly
True of the transport #protocol communicates with Ably with a binary protocol.
-
#use_tls? ⇒ Boolean
readonly
True if client is configured to use TLS for all Ably communication.
Instance Method Summary collapse
-
#auth_request_timeout ⇒ Object
private
Allowable duration for an external auth request For REST client this defaults to request_timeout For Realtime clients this defaults to 250ms less than the realtime_request_timeout ensuring an auth failure will be triggered before the realtime request timeout fires which would lead to a misleading error message (connection timeout as opposed to auth request timeout).
-
#channel(name, channel_options = {}) ⇒ Ably::Rest::Channel
Return a REST Channel for the given name.
-
#connection(options = {}) ⇒ Faraday::Connection
private
Connection used to make HTTP requests.
-
#delete(path, params, options = {}) ⇒ Faraday::Response
private
Perform an HTTP DELETE request to the API using configured authentication.
-
#device ⇒ Ably::Models::LocalDevice
Retrieves an object that represents the current state of the device as a target for push notifications.
-
#fallback_connection ⇒ Faraday::Connection
private
Fallback connection used to make HTTP requests.
-
#get(path, params = {}, options = {}) ⇒ Faraday::Response
private
Perform an HTTP GET request to the API using configured authentication.
-
#initialize(options) ⇒ Ably::Rest::Client
constructor
Constructs a Client object using an Ably API key or token string.
-
#post(path, params, options = {}) ⇒ Faraday::Response
private
Perform an HTTP POST request to the API using configured authentication.
-
#push ⇒ Ably::Rest::Push
A Push object.
-
#put(path, params, options = {}) ⇒ Faraday::Response
private
Perform an HTTP PUT request to the API using configured authentication.
-
#register_encoder(encoder, options = {}) ⇒ void
private
Register a message encoder and decoder that implements Ably::Models::MessageEncoders::Base interface.
-
#request(method, path, params = {}, body = nil, headers = {}, options = {}) ⇒ Ably::Models::HttpPaginatedResponse<>
Makes a REST request to a provided path.
-
#stats(options = {}) ⇒ Ably::Models::PaginatedResult<Ably::Models::Stats>
Queries the REST /stats API and retrieves your application’s usage statistics.
-
#time ⇒ Time
Retrieves the time from the Ably service as milliseconds since the Unix epoch.
-
#using_preferred_fallback_host? ⇒ nil, String
If the primary host endpoint fails, and a subsequent fallback host succeeds, the fallback host that succeeded is used for
ClientOption
fallback_retry_timeout
seconds to avoid retries to known failing hosts for a short period of time.
Constructor Details
#initialize(options) ⇒ Ably::Rest::Client
Constructs a Ably::Rest::Client object using an Ably API key or token string.
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 175 def initialize() raise ArgumentError, 'Options Hash is expected' if .nil? = .clone if .kind_of?(String) = if .match(Auth::API_KEY_REGEX) { key: } else { token: } end end @agent = .delete(:agent) || Ably::AGENT @realtime_client = .delete(:realtime_client) @tls = .delete(:tls) == false ? false : true @environment = .delete(:environment) # nil is production @environment = nil if [:production, 'production'].include?(@environment) @protocol = .delete(:protocol) || :msgpack @debug_http = .delete(:debug_http) @log_level = .delete(:log_level) || ::Logger::WARN @custom_logger = .delete(:logger) @custom_host = .delete(:rest_host) @custom_port = .delete(:port) @custom_tls_port = .delete(:tls_port) @add_request_ids = .delete(:add_request_ids) @log_retries_as_info = .delete(:log_retries_as_info) @max_message_size = .delete(:max_message_size) || MAX_MESSAGE_SIZE @max_frame_size = .delete(:max_frame_size) || MAX_FRAME_SIZE if (@idempotent_rest_publishing = .delete(:idempotent_rest_publishing)).nil? @idempotent_rest_publishing = Ably::PROTOCOL_VERSION.to_f > 1.1 end if [:fallback_hosts_use_default] && [:fallback_hosts] raise ArgumentError, "fallback_hosts_use_default cannot be set to try when fallback_hosts is also provided" end @fallback_hosts = case when .delete(:fallback_hosts_use_default) Ably::FALLBACK_HOSTS when = .delete(:fallback_hosts) when custom_host || [:realtime_host] || custom_port || custom_tls_port [] when environment CUSTOM_ENVIRONMENT_FALLBACKS_SUFFIXES.map { |host| "#{environment}#{host}" } else Ably::FALLBACK_HOSTS end [:fallback_retry_timeout] ||= FALLBACK_RETRY_TIMEOUT # Take option keys prefixed with `http_`, remove the http_ and # check if the option exists in HTTP_DEFAULTS. If so, update http_defaults @http_defaults = HTTP_DEFAULTS.dup .each do |key, val| if http_key = key[/^http_(.+)/, 1] # Typhoeus converts decimal durations to milliseconds, so 0.0001 timeout is treated as 0 (no timeout) val = 0.001 if val.kind_of?(Numeric) && (val > 0) && (val < 0.001) @http_defaults[http_key.to_sym] = val if val && @http_defaults.has_key?(http_key.to_sym) end end @http_defaults.freeze if @log_level == :none @custom_logger = Ably::Models::NilLogger.new else @log_level = ::Logger.const_get(log_level.to_s.upcase) if log_level.kind_of?(Symbol) || log_level.kind_of?(String) end .delete(:use_binary_protocol).tap do |use_binary_protocol| if use_binary_protocol == true @protocol = :msgpack elsif use_binary_protocol == false @protocol = :json end end raise ArgumentError, 'Protocol is invalid. Must be either :msgpack or :json' unless [:msgpack, :json].include?(@protocol) token_params = .delete(:default_token_params) || {} @options = = .select do |key, _| Auth::AUTH_OPTIONS_KEYS.include?(key.to_s) end @auth = Auth.new(self, token_params, ) @channels = Ably::Rest::Channels.new(self) @encoders = [] .freeze initialize_default_encoders end |
Instance Attribute Details
#add_request_ids ⇒ Boolean (readonly)
Whether the Ably::Rest::Client has to add a random identifier to the path of a request
104 105 106 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 104 def add_request_ids @add_request_ids end |
#agent ⇒ String (readonly)
Client agent i.e. ‘example-gem/1.2.0 ably-ruby/1.1.5 ruby/3.1.1`
55 56 57 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 55 def agent @agent end |
#auth ⇒ Ably::Auth (readonly)
An Auth object.
60 61 62 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 60 def auth @auth end |
#channels ⇒ Aby::Rest::Channels (readonly)
A Ably::Rest::Channels object.
65 66 67 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 65 def channels @channels end |
#custom_host ⇒ String, Nil (readonly)
The custom host that is being used if it was provided with the option :rest_host
when the Ably::Rest::Client was created
73 74 75 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 73 def custom_host @custom_host end |
#custom_port ⇒ Integer, Nil (readonly)
The custom port for non-TLS requests if it was provided with the option :port
when the Ably::Rest::Client was created
77 78 79 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 77 def custom_port @custom_port end |
#custom_tls_port ⇒ Integer, Nil (readonly)
The custom TLS port for TLS requests if it was provided with the option :tls_port
when the Ably::Rest::Client was created
81 82 83 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 81 def custom_tls_port @custom_tls_port end |
#encoders ⇒ Array<Ably::Models::MessageEncoder::Base> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The registered encoders that are used to encode and decode message payloads
91 92 93 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 91 def encoders @encoders end |
#endpoint ⇒ URI::Generic (readonly)
Returns Default Ably REST endpoint used for all requests.
433 434 435 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 433 def endpoint endpoint_for_host(custom_host || [@environment, DOMAIN].compact.join('-')) end |
#environment ⇒ String (readonly)
Custom environment to use such as ‘sandbox’ when testing the client library against an alternate Ably environment
47 48 49 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 47 def environment @environment end |
#fallback_hosts ⇒ Object (readonly)
The list of fallback hosts to be used by this client if empty or nil then fallback host functionality is disabled
100 101 102 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 100 def fallback_hosts @fallback_hosts end |
#http_defaults ⇒ Hash (readonly)
The immutable configured HTTP defaults for this client. See #initialize for the configurable HTTP defaults prefixed with http_
86 87 88 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 86 def http_defaults @http_defaults end |
#idempotent_rest_publishing ⇒ Boolean (readonly)
True when idempotent publishing is enabled for all messages published via REST. When this feature is enabled, the client library will add a unique ID to every published message (without an ID) ensuring any failed published attempts (due to failures such as HTTP requests failing mid-flight) that are automatically retried will not result in duplicate messages being published to the Ably platform. Note: This is a beta unsupported feature!
117 118 119 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 117 def idempotent_rest_publishing @idempotent_rest_publishing end |
#log_level ⇒ Logger::Severity (readonly)
Log level configured for this Ably::Rest::Client
69 70 71 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 69 def log_level @log_level end |
#log_retries_as_info ⇒ Boolean (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Retries are logged by default to warn and error. When true, retries are logged at info level
109 110 111 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 109 def log_retries_as_info @log_retries_as_info end |
#logger ⇒ Logger (readonly)
Returns The Logger for this client. Configure the log_level with the ‘:log_level` option, refer to #initialize.
440 441 442 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 440 def logger @logger ||= Ably::Logger.new(self, log_level, @custom_logger) end |
#max_frame_size ⇒ Integer (readonly)
Max frame size (TO2, TO3l8) by default (524288 bytes) 512KiB
125 126 127 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 125 def max_frame_size @max_frame_size end |
#max_message_size ⇒ Integer (readonly)
Max message size (TO2, TO3l8) by default (65536 bytes) 64KiB
121 122 123 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 121 def @max_message_size end |
#mime_type ⇒ String (readonly)
Returns Mime type used for HTTP requests.
446 447 448 449 450 451 452 453 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 446 def mime_type case protocol when :json 'application/json' else 'application/x-msgpack' end end |
#options ⇒ Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The additional options passed to this Client’s #initialize method not available as attributes of this class
96 97 98 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 96 def @options end |
#protocol ⇒ Symbol (readonly)
The protocol configured for this client, either binary ‘:msgpack` or text based `:json`
51 52 53 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 51 def protocol @protocol end |
#protocol_binary? ⇒ Boolean (readonly)
Returns True of the transport #protocol communicates with Ably with a binary protocol.
469 470 471 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 469 def protocol_binary? protocol == :msgpack end |
#use_tls? ⇒ Boolean (readonly)
Returns True if client is configured to use TLS for all Ably communication.
325 326 327 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 325 def use_tls? @tls == true end |
Instance Method Details
#auth_request_timeout ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Allowable duration for an external auth request For REST client this defaults to request_timeout For Realtime clients this defaults to 250ms less than the realtime_request_timeout
ensuring an auth failure will be triggered before the realtime request timeout fires
which would lead to a misleading error (connection timeout as opposed to auth request timeout)
513 514 515 516 517 518 519 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 513 def auth_request_timeout if @realtime_client @realtime_client.connection.defaults.fetch(:realtime_request_timeout) - 0.25 else http_defaults.fetch(:request_timeout) end end |
#channel(name, channel_options = {}) ⇒ Ably::Rest::Channel
Return a REST Ably::Rest::Channel for the given name
273 274 275 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 273 def channel(name, = {}) channels.get(name, ) end |
#connection(options = {}) ⇒ Faraday::Connection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Connection used to make HTTP requests
481 482 483 484 485 486 487 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 481 def connection( = {}) if [:use_fallback] fallback_connection else @connection ||= Faraday.new(endpoint.to_s, ) end end |
#delete(path, params, options = {}) ⇒ Faraday::Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Perform an HTTP DELETE request to the API using configured authentication
361 362 363 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 361 def delete(path, params, = {}) raw_request(:delete, path, params, ) end |
#device ⇒ Ably::Models::LocalDevice
This is unsupported in the Ruby library
Retrieves an object that represents the current state of the device as a target for push notifications.
420 421 422 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 420 def device raise Ably::Exceptions::PushNotificationsNotSupported, 'This device does not support receiving or subscribing to push notifications. The local device object is not unavailable' end |
#fallback_connection ⇒ Faraday::Connection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Fallback connection used to make HTTP requests. Note, each request uses a random and then subsequent random fallback hosts are used (unless custom fallback hosts are provided with fallback_hosts)
496 497 498 499 500 501 502 503 504 505 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 496 def fallback_connection unless defined?(@fallback_connections) && @fallback_connections @fallback_connections = fallback_hosts.shuffle.map { |host| Faraday.new(endpoint_for_host(host).to_s, ) } end @fallback_index ||= 0 @fallback_connections[@fallback_index % @fallback_connections.count].tap do @fallback_index += 1 end end |
#get(path, params = {}, options = {}) ⇒ Faraday::Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Perform an HTTP GET request to the API using configured authentication
334 335 336 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 334 def get(path, params = {}, = {}) raw_request(:get, path, params, ) end |
#post(path, params, options = {}) ⇒ Faraday::Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Perform an HTTP POST request to the API using configured authentication
343 344 345 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 343 def post(path, params, = {}) raw_request(:post, path, params, ) end |
#push ⇒ Ably::Rest::Push
A Push object.
427 428 429 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 427 def push @push ||= Push.new(self) end |
#put(path, params, options = {}) ⇒ Faraday::Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Perform an HTTP PUT request to the API using configured authentication
352 353 354 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 352 def put(path, params, = {}) raw_request(:put, path, params, ) end |
#register_encoder(encoder, options = {}) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Encoders and decoders are processed in the order they are added so the first encoder will be given priority when encoding and decoding
This method returns an undefined value.
Register a message encoder and decoder that implements Ably::Models::MessageEncoders::Base interface. Message encoders are used to encode and decode message payloads automatically.
463 464 465 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 463 def register_encoder(encoder, = {}) encoders << Ably::Models::MessageEncoders.encoder_from(encoder, ) end |
#request(method, path, params = {}, body = nil, headers = {}, options = {}) ⇒ Ably::Models::HttpPaginatedResponse<>
Makes a REST request to a provided path. This is provided as a convenience for developers who wish to use REST API functionality that is either not documented or is not yet included in the public API, without having to directly handle features such as authentication, paging, fallback hosts, MsgPack and JSON support.
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 378 def request(method, path, params = {}, body = nil, headers = {}, = {}) raise "Method #{method.to_s.upcase} not supported" unless %i(get put patch post delete).include?(method.to_sym) response = case method.to_sym when :get, :delete 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.") end path_with_params = Addressable::URI.new path_with_params.query_values = params || {} query = path_with_params.query do send_request(method, "#{path}#{"?#{query}" unless query.nil? || query.empty?}", body, headers: headers) end end = { async_blocking_operations: .delete(:async_blocking_operations), } Ably::Models::HttpPaginatedResponse.new(response, path, self, ) rescue Exceptions::ResourceMissing, Exceptions::ForbiddenRequest, Exceptions::ResourceMissing => e response = Models::HttpPaginatedResponse::ErrorResponse.new(e.status, e.code, e.) Models::HttpPaginatedResponse.new(response, path, self) rescue Exceptions::TokenExpired, Exceptions::UnauthorizedRequest => e response = Models::HttpPaginatedResponse::ErrorResponse.new(e.status, e.code, e.) Models::HttpPaginatedResponse.new(response, path, self) rescue Exceptions::InvalidRequest, Exceptions::ServerError => e response = Models::HttpPaginatedResponse::ErrorResponse.new(e.status, e.code, e.) Models::HttpPaginatedResponse.new(response, path, self) end |
#stats(options = {}) ⇒ Ably::Models::PaginatedResult<Ably::Models::Stats>
Queries the REST /stats API and retrieves your application’s usage statistics. Returns a Models::PaginatedResult object, containing an array of Models::Stats objects. See the Stats docs.
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 290 def stats( = {}) = { :direction => :backwards, :unit => :minute, :limit => 100 }.merge() [:start, :end].each { |option| [option] = as_since_epoch([option]) if .has_key?(option) } raise ArgumentError, ":end must be equal to or after :start" if [:start] && [:end] && ([:start] > [:end]) = { coerce_into: 'Ably::Models::Stats' } url = '/stats' response = get(url, ) Ably::Models::PaginatedResult.new(response, url, self, ) end |
#time ⇒ Time
Retrieves the time from the Ably service as milliseconds since the Unix epoch. Clients that do not have access to a sufficiently well maintained time source and wish to issue Ably Models::TokenRequest with a more accurate timestamp should use the #queryTime property instead of this method.
317 318 319 320 321 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 317 def time response = get('/time', {}, send_auth_header: false) as_time_from_epoch(response.body.first) end |
#using_preferred_fallback_host? ⇒ nil, String
If the primary host endpoint fails, and a subsequent fallback host succeeds, the fallback
host that succeeded is used for +ClientOption+ +fallback_retry_timeout+ seconds to avoid
retries to known failing hosts for a short period of time.
See github.com/ably/docs/pull/554, spec id #RSC15f
527 528 529 530 531 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/client.rb', line 527 def using_preferred_fallback_host? if preferred_fallback_connection && (preferred_fallback_connection.fetch(:expires_at) > Time.now) preferred_fallback_connection.fetch(:connection_object).host end end |