oci 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +26 -1
- data/lib/oci.rb +1 -0
- data/lib/oci/audit/audit_client.rb +65 -30
- data/lib/oci/audit/models/audit_event.rb +17 -1
- data/lib/oci/core/blockstorage_client.rb +336 -197
- data/lib/oci/core/compute_client.rb +601 -357
- data/lib/oci/core/models/attach_volume_details.rb +4 -0
- data/lib/oci/core/models/boot_volume.rb +1 -1
- data/lib/oci/core/models/dhcp_option.rb +4 -0
- data/lib/oci/core/models/export_image_details.rb +4 -0
- data/lib/oci/core/models/image_source_details.rb +4 -0
- data/lib/oci/core/models/instance_source_details.rb +4 -0
- data/lib/oci/core/models/volume_attachment.rb +4 -0
- data/lib/oci/core/models/volume_source_details.rb +4 -0
- data/lib/oci/core/util.rb +29 -0
- data/lib/oci/core/virtual_network_client.rb +1695 -1031
- data/lib/oci/database/database_client.rb +612 -368
- data/lib/oci/database/models/create_data_guard_association_details.rb +4 -0
- data/lib/oci/database/models/create_db_home_with_db_system_id_base.rb +4 -0
- data/lib/oci/dns/dns_client.rb +271 -158
- data/lib/oci/email/email_client.rb +144 -79
- data/lib/oci/file_storage/file_storage_client.rb +354 -207
- data/lib/oci/identity/identity_client.rb +1111 -670
- data/lib/oci/identity/models/create_identity_provider_details.rb +4 -0
- data/lib/oci/identity/models/identity_provider.rb +4 -0
- data/lib/oci/identity/models/update_identity_provider_details.rb +4 -0
- data/lib/oci/load_balancer/load_balancer.rb +4 -0
- data/lib/oci/load_balancer/load_balancer_client.rb +943 -383
- data/lib/oci/load_balancer/load_balancer_client_composite_operations.rb +149 -17
- data/lib/oci/load_balancer/models/backend.rb +5 -5
- data/lib/oci/load_balancer/models/backend_details.rb +4 -4
- data/lib/oci/load_balancer/models/backend_set.rb +1 -1
- data/lib/oci/load_balancer/models/backend_set_health.rb +4 -4
- data/lib/oci/load_balancer/models/certificate.rb +2 -2
- data/lib/oci/load_balancer/models/certificate_details.rb +2 -4
- data/lib/oci/load_balancer/models/connection_configuration.rb +1 -28
- data/lib/oci/load_balancer/models/create_backend_details.rb +4 -4
- data/lib/oci/load_balancer/models/create_backend_set_details.rb +1 -1
- data/lib/oci/load_balancer/models/create_certificate_details.rb +5 -7
- data/lib/oci/load_balancer/models/create_hostname_details.rb +164 -0
- data/lib/oci/load_balancer/models/create_listener_details.rb +19 -5
- data/lib/oci/load_balancer/models/create_load_balancer_details.rb +12 -3
- data/lib/oci/load_balancer/models/create_path_route_set_details.rb +1 -1
- data/lib/oci/load_balancer/models/health_check_result.rb +2 -2
- data/lib/oci/load_balancer/models/health_checker.rb +3 -3
- data/lib/oci/load_balancer/models/health_checker_details.rb +3 -3
- data/lib/oci/load_balancer/models/hostname.rb +164 -0
- data/lib/oci/load_balancer/models/hostname_details.rb +163 -0
- data/lib/oci/load_balancer/models/ip_address.rb +1 -1
- data/lib/oci/load_balancer/models/listener.rb +19 -5
- data/lib/oci/load_balancer/models/listener_details.rb +17 -3
- data/lib/oci/load_balancer/models/load_balancer.rb +13 -2
- data/lib/oci/load_balancer/models/load_balancer_health.rb +3 -3
- data/lib/oci/load_balancer/models/load_balancer_policy.rb +4 -1
- data/lib/oci/load_balancer/models/load_balancer_protocol.rb +5 -2
- data/lib/oci/load_balancer/models/load_balancer_shape.rb +3 -0
- data/lib/oci/load_balancer/models/path_route.rb +1 -1
- data/lib/oci/load_balancer/models/path_route_set.rb +1 -1
- data/lib/oci/load_balancer/models/session_persistence_configuration_details.rb +2 -2
- data/lib/oci/load_balancer/models/ssl_configuration.rb +1 -1
- data/lib/oci/load_balancer/models/ssl_configuration_details.rb +1 -1
- data/lib/oci/load_balancer/models/update_backend_details.rb +3 -3
- data/lib/oci/load_balancer/models/update_health_checker_details.rb +3 -3
- data/lib/oci/load_balancer/models/update_hostname_details.rb +153 -0
- data/lib/oci/load_balancer/models/update_listener_details.rb +17 -3
- data/lib/oci/load_balancer/models/update_load_balancer_details.rb +1 -1
- data/lib/oci/load_balancer/models/work_request.rb +2 -0
- data/lib/oci/object_storage/object_storage_client.rb +443 -270
- data/lib/oci/retry/functions/should_retry_on_error.rb +28 -0
- data/lib/oci/retry/functions/sleep.rb +85 -0
- data/lib/oci/retry/internal/retry_state.rb +48 -0
- data/lib/oci/retry/retry.rb +85 -0
- data/lib/oci/retry/retry_config.rb +121 -0
- data/lib/oci/version.rb +1 -1
- metadata +39 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
module OCI
|
|
4
|
+
module Retry
|
|
5
|
+
module Functions
|
|
6
|
+
# A module containing functions that can be used to determine whether to retry based on
|
|
7
|
+
# the error/exception encountered.
|
|
8
|
+
#
|
|
9
|
+
# These functions should take a single argument of a {OCI::Retry::Internal::RetryState}
|
|
10
|
+
# object
|
|
11
|
+
module ShouldRetryOnError
|
|
12
|
+
# Returns a proc which will retry on {OCI::Errors::NetworkError} and on {OCI::Errors::ServiceError}
|
|
13
|
+
# when the status code indicates a throttle (HTTP 429) or an internal server error
|
|
14
|
+
# (any HTTP 5xx)
|
|
15
|
+
#
|
|
16
|
+
# @return [Proc]
|
|
17
|
+
def self.retry_on_network_error_throttle_and_internal_server_errors
|
|
18
|
+
lambda do |retry_state|
|
|
19
|
+
return true if retry_state.last_exception.is_a?(OCI::Errors::NetworkError)
|
|
20
|
+
return false unless retry_state.last_exception.is_a?(OCI::Errors::ServiceError)
|
|
21
|
+
|
|
22
|
+
retry_state.last_exception.status_code == 429 || retry_state.last_exception.status_code >= 500
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
module OCI
|
|
4
|
+
module Retry
|
|
5
|
+
module Functions
|
|
6
|
+
# A module containing functions that can be used to calculate sleep times between retries.
|
|
7
|
+
#
|
|
8
|
+
# These functions should take two arguments: the first argument an object of type
|
|
9
|
+
# {OCI::Retry::RetryConfig} and the second an object of type {OCI::Retry::Internal::RetryState}
|
|
10
|
+
module Sleep
|
|
11
|
+
# Returns a proc which applies an exponential backoff with full jitter calculation. This is
|
|
12
|
+
# defined as:
|
|
13
|
+
#
|
|
14
|
+
# random(0, min(base_sleep_time * (exponent**attempts), max_sleep_time_between_attempts))
|
|
15
|
+
#
|
|
16
|
+
# Where the base_sleep_time, exponent, max_sleep_time_between_attempts is taken from the
|
|
17
|
+
# {OCI::Retry::RetryConfig} provided to the proc and the attempts is taken from the
|
|
18
|
+
# {OCI::Retry::Internal::RetryState} provided to the proc.
|
|
19
|
+
#
|
|
20
|
+
# @return [Proc]
|
|
21
|
+
def self.exponential_backoff_with_full_jitter
|
|
22
|
+
lambda do |retry_config, retry_state|
|
|
23
|
+
random = Random.new
|
|
24
|
+
attempt = retry_state.current_attempt_number
|
|
25
|
+
base_sleep_millis = retry_config.base_sleep_time_millis
|
|
26
|
+
exponential_growth_factor = retry_config.exponential_growth_factor
|
|
27
|
+
max_sleep_time_millis = retry_config.max_sleep_between_attempts_millis
|
|
28
|
+
|
|
29
|
+
return random.rand(0..(base_sleep_millis * (exponential_growth_factor**attempt))) \
|
|
30
|
+
if max_sleep_time_millis.nil?
|
|
31
|
+
|
|
32
|
+
random.rand(0..[base_sleep_millis * (exponential_growth_factor**attempt), max_sleep_time_millis].min)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
# rubocop:disable Metrics/AbcSize, Layout/EmptyLines
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# Returns a proc which applies an exponential backoff with equal jitter calclulation. This is defined as:
|
|
39
|
+
#
|
|
40
|
+
# base_sleep_time = min(base_sleep_time * (exponent**attempts), max_sleep_time)
|
|
41
|
+
# (base_sleep_time / 2) + random(0, (base_sleep_time / 2))
|
|
42
|
+
#
|
|
43
|
+
# Where the base_sleep_time, exponent, max_sleep_time_between_attempts is taken from the
|
|
44
|
+
# {OCI::Retry::RetryConfig} provided to the proc and the attempts is taken from the
|
|
45
|
+
# {OCI::Retry::Internal::RetryState} provided to the proc.
|
|
46
|
+
#
|
|
47
|
+
# @return [Proc]
|
|
48
|
+
def self.exponential_backoff_with_equal_jitter
|
|
49
|
+
lambda do |retry_config, retry_state|
|
|
50
|
+
random = Random.new
|
|
51
|
+
attempt = retry_state.current_attempt_number
|
|
52
|
+
base_sleep_millis = retry_config.base_sleep_time_millis
|
|
53
|
+
exponential_growth_factor = retry_config.exponential_growth_factor
|
|
54
|
+
max_sleep_time_millis = retry_config.max_sleep_between_attempts_millis
|
|
55
|
+
|
|
56
|
+
sleep_raw = if max_sleep_time_millis.nil?
|
|
57
|
+
base_sleep_millis * (exponential_growth_factor**attempt)
|
|
58
|
+
else
|
|
59
|
+
[base_sleep_millis * (exponential_growth_factor**attempt), max_sleep_time_millis].min
|
|
60
|
+
end
|
|
61
|
+
(sleep_raw / 2) + random.rand(0..(sleep_raw / 2))
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
# rubocop:enable Metrics/AbcSize, Layout/EmptyLines
|
|
65
|
+
|
|
66
|
+
# Returns a proc which uses exponential backoff with full jitter for retries, except in the case of
|
|
67
|
+
# throttles where exponential backoff with equal jitter is used instead. This ensures some base
|
|
68
|
+
# level of sleep for throttles rather than, potentially, retrying again in quick succession
|
|
69
|
+
#
|
|
70
|
+
# @return [Proc]
|
|
71
|
+
def self.exponential_backoff_with_full_jitter_equal_on_throttle
|
|
72
|
+
lambda do |retry_config, retry_state|
|
|
73
|
+
use_equal_jitter =
|
|
74
|
+
!retry_state.last_exception.nil? &&
|
|
75
|
+
retry_state.last_exception.respond_to?(:status_code) &&
|
|
76
|
+
retry_state.last_exception.status_code == 429
|
|
77
|
+
|
|
78
|
+
return exponential_backoff_with_full_jitter.call(retry_config, retry_state) unless use_equal_jitter
|
|
79
|
+
exponential_backoff_with_equal_jitter.call(retry_config, retry_state)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
require 'time'
|
|
4
|
+
|
|
5
|
+
module OCI
|
|
6
|
+
module Retry
|
|
7
|
+
module Internal
|
|
8
|
+
# A property bag containing the current state of making a retriable call
|
|
9
|
+
class RetryState
|
|
10
|
+
# The current number of attempts which have been made. This is one-based (i.e. the first attempt is 1,
|
|
11
|
+
# the second is 2 etc.)
|
|
12
|
+
attr_reader :current_attempt_number
|
|
13
|
+
|
|
14
|
+
# When we started making retriable calls, in epoch milliseconds
|
|
15
|
+
#
|
|
16
|
+
# @return [Integer]
|
|
17
|
+
attr_reader :start_time_epoch_millis
|
|
18
|
+
|
|
19
|
+
# The last exception which was raised when making a retriable call
|
|
20
|
+
#
|
|
21
|
+
# @return [Exception]
|
|
22
|
+
attr_accessor :last_exception
|
|
23
|
+
|
|
24
|
+
def initialize
|
|
25
|
+
@current_attempt_number = 0
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Increments the number of attempts which have been made by 1
|
|
29
|
+
def increment_attempts
|
|
30
|
+
@current_attempt_number += 1
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Sets the {#start_time_epoch_millis} property to the current time in epoch milliseconds. This can
|
|
34
|
+
# only be done once.
|
|
35
|
+
def start
|
|
36
|
+
raise 'The start_time for the retry state has already been set' unless @start_time_epoch_millis.nil?
|
|
37
|
+
@start_time_epoch_millis = (Time.now.to_f * 1000).to_i
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def to_s
|
|
41
|
+
"{ 'current_attempt': '#{current_attempt_number}', " \
|
|
42
|
+
"'start_time_epoch_millis': '#{start_time_epoch_millis}', " \
|
|
43
|
+
"'last_exception': '#{last_exception}' }"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
module OCI
|
|
4
|
+
# Module for retry strategies for use with the SDK when calling OCI services
|
|
5
|
+
module Retry
|
|
6
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Layout/EmptyLines
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# Takes a block and then executes it with retries based on the provided configuration.
|
|
10
|
+
#
|
|
11
|
+
# @param [OCI::Retry::RetryConfig] retry_config The configuration to be used for retries, defining what
|
|
12
|
+
# exceptions to retry on, how to calculate sleep times between retries etc. If the parameter value is nil
|
|
13
|
+
# then no retries are performed and the block is called once
|
|
14
|
+
#
|
|
15
|
+
# @param [String] operation_name A friendly name for the operation being called so that it can be written
|
|
16
|
+
# to the logs
|
|
17
|
+
#
|
|
18
|
+
# @return [Object] The result of the block passed to this method
|
|
19
|
+
def self.make_retrying_call(retry_config, call_name: nil)
|
|
20
|
+
raise 'A block must be provided' unless block_given?
|
|
21
|
+
|
|
22
|
+
# If no retry configuration has been given, just do a single call
|
|
23
|
+
return yield if retry_config.nil?
|
|
24
|
+
|
|
25
|
+
retry_state = OCI::Retry::Internal::RetryState.new
|
|
26
|
+
retry_state.start
|
|
27
|
+
|
|
28
|
+
loop do
|
|
29
|
+
begin
|
|
30
|
+
OCI.logger.debug("[RETRYING_CALL] #{call_name}") if OCI.logger
|
|
31
|
+
return yield
|
|
32
|
+
rescue => e # rubocop:disable Style/RescueStandardError
|
|
33
|
+
retry_state.increment_attempts
|
|
34
|
+
retry_state.last_exception = e
|
|
35
|
+
if retry_config.should_retry?(retry_state)
|
|
36
|
+
if OCI.logger
|
|
37
|
+
OCI.logger.debug(
|
|
38
|
+
"[RETRYING] #{call_name} failed. Sleeping then retrying. Retry state: #{retry_state}"
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
retry_config.do_sleep(retry_state)
|
|
42
|
+
else
|
|
43
|
+
if OCI.logger
|
|
44
|
+
OCI.logger.debug(
|
|
45
|
+
"[RETRIES_EXHAUSTED] #{call_name} failed and exhausted retries. Retry state: #{retry_state}"
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
raise
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Layout/EmptyLines
|
|
54
|
+
|
|
55
|
+
# Generates a token which can be used as a value for the opc-retry-token header value. The token will
|
|
56
|
+
# consist of uppercase letters (A-Z), lowercase letters (a-z) and digits (0-9)
|
|
57
|
+
#
|
|
58
|
+
# @param [Integer] token_length how many characters the token should be
|
|
59
|
+
#
|
|
60
|
+
# @return [String]
|
|
61
|
+
def self.generate_opc_retry_token(token_length = 32)
|
|
62
|
+
raise 'The token must be at least one character long' if token_length.nil? || token_length < 1
|
|
63
|
+
|
|
64
|
+
available_chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
|
|
65
|
+
retry_token = ''
|
|
66
|
+
token_length.times { retry_token << available_chars[rand(available_chars.size)] }
|
|
67
|
+
|
|
68
|
+
retry_token
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# A module containing functions that can be used with retries (e.g. for sleeping and working
|
|
72
|
+
# out whether a particular error/exception can be retried)
|
|
73
|
+
module Functions
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Internal functionality to support the {OCI::Retry} module. Not intended for public use.
|
|
77
|
+
module Internal
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
require 'oci/retry/retry_config'
|
|
83
|
+
require 'oci/retry/functions/should_retry_on_error'
|
|
84
|
+
require 'oci/retry/functions/sleep'
|
|
85
|
+
require 'oci/retry/internal/retry_state'
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
require 'time'
|
|
4
|
+
|
|
5
|
+
module OCI
|
|
6
|
+
module Retry
|
|
7
|
+
# The configuration for a retry strategy
|
|
8
|
+
class RetryConfig
|
|
9
|
+
# The maximum number of attempts before we stop trying to make calls. This is one-based (i.e. the first attempt is 1,
|
|
10
|
+
# the second is 2 etc.) and nil indicates that there is no maximum.
|
|
11
|
+
#
|
|
12
|
+
# @return [Integer]
|
|
13
|
+
attr_reader :max_attempts
|
|
14
|
+
|
|
15
|
+
# The maximum amount of time (in milliseconds) that can elapse for all attempts before we stop trying
|
|
16
|
+
# to make calls. A nil value indicates that there is no maximum
|
|
17
|
+
#
|
|
18
|
+
# @return [Integer]
|
|
19
|
+
attr_reader :max_elapsed_time_millis
|
|
20
|
+
|
|
21
|
+
# A proc which can be called to determine whether a particular exception can be retried. This proc should
|
|
22
|
+
# take a single argument of type {OCI::Retry::Internal::RetryState}. The exception can be accessed via
|
|
23
|
+
# {OCI::Retry::Intenral::RetryState#last_exception}
|
|
24
|
+
#
|
|
25
|
+
# @return [Proc]
|
|
26
|
+
attr_reader :should_retry_exception_proc
|
|
27
|
+
|
|
28
|
+
# A proc which can be called to determine the next sleep time (in milliseconds) when retrying. This proc
|
|
29
|
+
# should take two arguments, the first argument of type {OCI::Retry::RetryConfig} and the second of type
|
|
30
|
+
# {OCI::Retry::Internal::RetryState}
|
|
31
|
+
#
|
|
32
|
+
# @return [Proc]
|
|
33
|
+
attr_reader :sleep_calc_millis_proc
|
|
34
|
+
|
|
35
|
+
# For exponential backoff and retry calculations, the base time (in milliseconds) which we multiply by
|
|
36
|
+
# some exponential value
|
|
37
|
+
#
|
|
38
|
+
# @return [Integer]
|
|
39
|
+
attr_reader :base_sleep_time_millis
|
|
40
|
+
|
|
41
|
+
# For exponential backoff and retry calculations, the exponent we'll raise to the number of attempts.
|
|
42
|
+
# The result would then be multiplied by the value in {#base_sleep_time_millis}
|
|
43
|
+
#
|
|
44
|
+
# @return [Integer]
|
|
45
|
+
attr_reader :exponential_growth_factor
|
|
46
|
+
|
|
47
|
+
# For exponential backoff and retry calclulation, the maximum amount of time (in milliseconds) to
|
|
48
|
+
# sleep between attempts. A nil value indicates that there is no maximum
|
|
49
|
+
#
|
|
50
|
+
# @return [Integer]
|
|
51
|
+
attr_reader :max_sleep_between_attempts_millis
|
|
52
|
+
|
|
53
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Layout/EmptyLines
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def initialize(
|
|
57
|
+
base_sleep_time_millis:,
|
|
58
|
+
exponential_growth_factor:,
|
|
59
|
+
should_retry_exception_proc:,
|
|
60
|
+
sleep_calc_millis_proc:,
|
|
61
|
+
max_attempts: nil,
|
|
62
|
+
max_elapsed_time_millis: nil,
|
|
63
|
+
max_sleep_between_attempts_millis: nil
|
|
64
|
+
)
|
|
65
|
+
raise 'base_sleep_time_millis must be greater than or equal to 1' \
|
|
66
|
+
if base_sleep_time_millis.nil? || base_sleep_time_millis < 1
|
|
67
|
+
|
|
68
|
+
raise 'exponential_growth_factor must be greater than or equal to 1' \
|
|
69
|
+
if exponential_growth_factor.nil? || exponential_growth_factor < 1
|
|
70
|
+
|
|
71
|
+
raise 'should_retry_exception_proc must be provided' if should_retry_exception_proc.nil?
|
|
72
|
+
raise 'sleep_calc_millis_proc must be provided' if sleep_calc_millis_proc.nil?
|
|
73
|
+
|
|
74
|
+
@base_sleep_time_millis = base_sleep_time_millis
|
|
75
|
+
@exponential_growth_factor = exponential_growth_factor
|
|
76
|
+
@should_retry_exception_proc = should_retry_exception_proc
|
|
77
|
+
@sleep_calc_millis_proc = sleep_calc_millis_proc
|
|
78
|
+
|
|
79
|
+
unless max_attempts.nil?
|
|
80
|
+
raise 'max_attempts must be greater than or equal to 1' if max_attempts < 1
|
|
81
|
+
@max_attempts = max_attempts
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
unless max_elapsed_time_millis.nil?
|
|
85
|
+
raise 'max_elapsed_time_millis must be greater than or equal to 0' if max_elapsed_time_millis < 0
|
|
86
|
+
@max_elapsed_time_millis = max_elapsed_time_millis
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
raise 'max_sleep_between_attempts_millis must be greater than or equal to 0' \
|
|
90
|
+
if max_sleep_between_attempts_millis && max_sleep_between_attempts_millis < 0
|
|
91
|
+
@max_sleep_between_attempts_millis = max_sleep_between_attempts_millis if max_sleep_between_attempts_millis
|
|
92
|
+
end
|
|
93
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Layout/EmptyLines
|
|
94
|
+
|
|
95
|
+
# Determines whether we should retry a call based on the current state of making a retriable call and the values
|
|
96
|
+
# defined in this configuration.
|
|
97
|
+
#
|
|
98
|
+
# @param [OCI::Retry::Internal::RetryState] retry_state The current state of making a retriable call
|
|
99
|
+
#
|
|
100
|
+
# @return [Boolean] true if we should retry based on the current state and this configuration, and false
|
|
101
|
+
# otherwise
|
|
102
|
+
def should_retry?(retry_state)
|
|
103
|
+
current_time = (Time.now.to_f * 1000).to_i
|
|
104
|
+
time_difference_millis = current_time - retry_state.start_time_epoch_millis
|
|
105
|
+
|
|
106
|
+
return false if @max_attempts && retry_state.current_attempt_number >= @max_attempts
|
|
107
|
+
return false if @max_elapsed_time_millis && time_difference_millis > @max_elapsed_time_millis
|
|
108
|
+
|
|
109
|
+
should_retry_exception_proc.call(retry_state)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Sleeps for some amount of time based on the current state of making a retriable call
|
|
113
|
+
#
|
|
114
|
+
# @param [OCI::Retry::Internal::RetryState] retry_state The current state of making a retriable call
|
|
115
|
+
def do_sleep(retry_state)
|
|
116
|
+
sleep_time_millis = sleep_calc_millis_proc.call(self, retry_state)
|
|
117
|
+
sleep(sleep_time_millis / 1000.0)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
data/lib/oci/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oci
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Oracle
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-05-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|
|
@@ -98,14 +98,20 @@ dependencies:
|
|
|
98
98
|
requirements:
|
|
99
99
|
- - "~>"
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: 0.
|
|
101
|
+
version: '0.9'
|
|
102
|
+
- - ">="
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: 0.9.12
|
|
102
105
|
type: :development
|
|
103
106
|
prerelease: false
|
|
104
107
|
version_requirements: !ruby/object:Gem::Requirement
|
|
105
108
|
requirements:
|
|
106
109
|
- - "~>"
|
|
107
110
|
- !ruby/object:Gem::Version
|
|
108
|
-
version: 0.
|
|
111
|
+
version: '0.9'
|
|
112
|
+
- - ">="
|
|
113
|
+
- !ruby/object:Gem::Version
|
|
114
|
+
version: 0.9.12
|
|
109
115
|
- !ruby/object:Gem::Dependency
|
|
110
116
|
name: os
|
|
111
117
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -120,6 +126,26 @@ dependencies:
|
|
|
120
126
|
- - "~>"
|
|
121
127
|
- !ruby/object:Gem::Version
|
|
122
128
|
version: '1.0'
|
|
129
|
+
- !ruby/object:Gem::Dependency
|
|
130
|
+
name: rubocop
|
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
|
132
|
+
requirements:
|
|
133
|
+
- - "~>"
|
|
134
|
+
- !ruby/object:Gem::Version
|
|
135
|
+
version: '0'
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0.55'
|
|
139
|
+
type: :development
|
|
140
|
+
prerelease: false
|
|
141
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - "~>"
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
- - ">="
|
|
147
|
+
- !ruby/object:Gem::Version
|
|
148
|
+
version: '0.55'
|
|
123
149
|
description: Ruby SDK for Oracle Cloud Infrastructure.
|
|
124
150
|
email:
|
|
125
151
|
- joe.levy@oracle.com
|
|
@@ -462,12 +488,15 @@ files:
|
|
|
462
488
|
- "./lib/oci/load_balancer/models/create_backend_details.rb"
|
|
463
489
|
- "./lib/oci/load_balancer/models/create_backend_set_details.rb"
|
|
464
490
|
- "./lib/oci/load_balancer/models/create_certificate_details.rb"
|
|
491
|
+
- "./lib/oci/load_balancer/models/create_hostname_details.rb"
|
|
465
492
|
- "./lib/oci/load_balancer/models/create_listener_details.rb"
|
|
466
493
|
- "./lib/oci/load_balancer/models/create_load_balancer_details.rb"
|
|
467
494
|
- "./lib/oci/load_balancer/models/create_path_route_set_details.rb"
|
|
468
495
|
- "./lib/oci/load_balancer/models/health_check_result.rb"
|
|
469
496
|
- "./lib/oci/load_balancer/models/health_checker.rb"
|
|
470
497
|
- "./lib/oci/load_balancer/models/health_checker_details.rb"
|
|
498
|
+
- "./lib/oci/load_balancer/models/hostname.rb"
|
|
499
|
+
- "./lib/oci/load_balancer/models/hostname_details.rb"
|
|
471
500
|
- "./lib/oci/load_balancer/models/ip_address.rb"
|
|
472
501
|
- "./lib/oci/load_balancer/models/listener.rb"
|
|
473
502
|
- "./lib/oci/load_balancer/models/listener_details.rb"
|
|
@@ -487,6 +516,7 @@ files:
|
|
|
487
516
|
- "./lib/oci/load_balancer/models/update_backend_details.rb"
|
|
488
517
|
- "./lib/oci/load_balancer/models/update_backend_set_details.rb"
|
|
489
518
|
- "./lib/oci/load_balancer/models/update_health_checker_details.rb"
|
|
519
|
+
- "./lib/oci/load_balancer/models/update_hostname_details.rb"
|
|
490
520
|
- "./lib/oci/load_balancer/models/update_listener_details.rb"
|
|
491
521
|
- "./lib/oci/load_balancer/models/update_load_balancer_details.rb"
|
|
492
522
|
- "./lib/oci/load_balancer/models/update_path_route_set_details.rb"
|
|
@@ -526,6 +556,11 @@ files:
|
|
|
526
556
|
- "./lib/oci/regions.rb"
|
|
527
557
|
- "./lib/oci/response.rb"
|
|
528
558
|
- "./lib/oci/response_headers.rb"
|
|
559
|
+
- "./lib/oci/retry/functions/should_retry_on_error.rb"
|
|
560
|
+
- "./lib/oci/retry/functions/sleep.rb"
|
|
561
|
+
- "./lib/oci/retry/internal/retry_state.rb"
|
|
562
|
+
- "./lib/oci/retry/retry.rb"
|
|
563
|
+
- "./lib/oci/retry/retry_config.rb"
|
|
529
564
|
- "./lib/oci/signer.rb"
|
|
530
565
|
- "./lib/oci/version.rb"
|
|
531
566
|
- "./lib/oci/waiter.rb"
|