use custom retry strategy for bad network
This commit is contained in:
+1
-1
@@ -9,4 +9,4 @@ def init_logger():
|
||||
filemode='a',
|
||||
format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S',
|
||||
level=logging.DEBUG)
|
||||
level=logging.INFO)
|
||||
|
||||
+33
-1
@@ -30,12 +30,44 @@ LOG_APPOINTMENT_TIMEOUT = "TIMEOUT"
|
||||
LOG_APPOINTMENT_CONTACT_NOT_FOUND = "CONTACT_NOT_FOUND"
|
||||
LOG_APPOINTMENT_SUCCESS = "SUCCESS"
|
||||
|
||||
custom_retry_strategy = oci.retry.RetryStrategyBuilder(
|
||||
# Make up to 10 service calls
|
||||
max_attempts_check=True,
|
||||
max_attempts=10,
|
||||
|
||||
# Don't exceed a total of 600 seconds for all service calls
|
||||
total_elapsed_time_check=True,
|
||||
total_elapsed_time_seconds=600,
|
||||
|
||||
# Wait 45 seconds between attempts
|
||||
retry_max_wait_between_calls_seconds=45,
|
||||
|
||||
# Use 2 seconds as the base number for doing sleep time calculations
|
||||
retry_base_sleep_time_seconds=2,
|
||||
|
||||
# Retry on certain service errors:
|
||||
#
|
||||
# - 5xx code received for the request
|
||||
# - Any 429 (this is signified by the empty array in the retry config)
|
||||
# - 400s where the code is QuotaExceeded or LimitExceeded
|
||||
service_error_check=True,
|
||||
service_error_retry_on_any_5xx=True,
|
||||
service_error_retry_config={
|
||||
400: ['QuotaExceeded', 'LimitExceeded'],
|
||||
429: []
|
||||
},
|
||||
|
||||
# Use exponential backoff and retry with full jitter, but on throttles use
|
||||
# exponential backoff and retry with equal jitter
|
||||
backoff_type=oci.retry.BACKOFF_FULL_JITTER_EQUAL_ON_THROTTLE_VALUE
|
||||
).get_retry_strategy()
|
||||
|
||||
|
||||
class LogSender:
|
||||
def __init__(self):
|
||||
self._config = oci.config.from_file("~/.oci/logger_config_appointment")
|
||||
self._identity = oci.identity.IdentityClient(self._config)
|
||||
self._loggingingestion_client = LoggingClient(self._config,timeout=60.0)
|
||||
self._loggingingestion_client = LoggingClient(self._config, timeout=60.0, retry_strategy=custom_retry_strategy)
|
||||
|
||||
def send_appoint_result(self, result: ReserveResultPojo):
|
||||
if result.type == PublishType.SUCCESS:
|
||||
|
||||
Reference in New Issue
Block a user