[457] | 1 | // Copyright (c) Microsoft. All rights reserved.
|
---|
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
---|
| 3 |
|
---|
| 4 | #ifndef IOTHUB_CLIENT_RETRY_CONTROL
|
---|
| 5 | #define IOTHUB_CLIENT_RETRY_CONTROL
|
---|
| 6 |
|
---|
| 7 | #include <stdlib.h>
|
---|
| 8 | #include <stdbool.h>
|
---|
| 9 | #include "azure_c_shared_utility/optionhandler.h"
|
---|
| 10 | #include "umock_c/umock_c_prod.h"
|
---|
| 11 | #include "iothub_client_core_ll.h"
|
---|
| 12 | #include "internal/iothubtransport.h"
|
---|
| 13 | #include "azure_c_shared_utility/const_defines.h"
|
---|
| 14 |
|
---|
| 15 | #ifdef __cplusplus
|
---|
| 16 | extern "C"
|
---|
| 17 | {
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
| 20 | static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_INITIAL_WAIT_TIME_IN_SECS = "initial_wait_time_in_secs";
|
---|
| 21 | static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_MAX_JITTER_PERCENT = "max_jitter_percent";
|
---|
| 22 | static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_MAX_DELAY_IN_SECS = "max_delay_in_secs";
|
---|
| 23 | static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_SAVED_OPTIONS = "retry_control_saved_options";
|
---|
| 24 |
|
---|
| 25 | typedef enum RETRY_ACTION_TAG
|
---|
| 26 | {
|
---|
| 27 | RETRY_ACTION_RETRY_NOW,
|
---|
| 28 | RETRY_ACTION_RETRY_LATER,
|
---|
| 29 | RETRY_ACTION_STOP_RETRYING
|
---|
| 30 | } RETRY_ACTION;
|
---|
| 31 |
|
---|
| 32 | struct RETRY_CONTROL_INSTANCE_TAG;
|
---|
| 33 | typedef struct RETRY_CONTROL_INSTANCE_TAG* RETRY_CONTROL_HANDLE;
|
---|
| 34 |
|
---|
| 35 | MOCKABLE_FUNCTION(, RETRY_CONTROL_HANDLE, retry_control_create, IOTHUB_CLIENT_RETRY_POLICY, policy, unsigned int, max_retry_time_in_secs);
|
---|
| 36 | MOCKABLE_FUNCTION(, int, retry_control_should_retry, RETRY_CONTROL_HANDLE, retry_control_handle, RETRY_ACTION*, retry_action);
|
---|
| 37 | MOCKABLE_FUNCTION(, void, retry_control_reset, RETRY_CONTROL_HANDLE, retry_control_handle);
|
---|
| 38 | MOCKABLE_FUNCTION(, int, retry_control_set_option, RETRY_CONTROL_HANDLE, retry_control_handle, const char*, name, const void*, value);
|
---|
| 39 | MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, retry_control_retrieve_options, RETRY_CONTROL_HANDLE, retry_control_handle);
|
---|
| 40 | MOCKABLE_FUNCTION(, void, retry_control_destroy, RETRY_CONTROL_HANDLE, retry_control_handle);
|
---|
| 41 |
|
---|
| 42 | MOCKABLE_FUNCTION(, int, is_timeout_reached, time_t, start_time, unsigned int, timeout_in_secs, bool*, is_timed_out);
|
---|
| 43 |
|
---|
| 44 | #ifdef __cplusplus
|
---|
| 45 | }
|
---|
| 46 | #endif
|
---|
| 47 |
|
---|
| 48 | #endif // IOTHUB_CLIENT_RETRY_CONTROL
|
---|