Coverage for src / augint_library / constants.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-30 20:22 +0000

1"""Constants for augint-library configuration values. 

2 

3This module provides named constants for all magic numbers used throughout the library, 

4improving maintainability and providing a single source of truth for configuration values. 

5 

6The constants are organized into logical groups: 

7- Resilience: Retry and circuit breaker configuration 

8- Network: API timeouts and connection settings 

9- Percentage: Rate and percentage boundaries 

10- Hash/ID: Hashing and identifier configuration 

11- CLI: Command-line interface specific values 

12- Data Processing: Batch and formatting settings 

13""" 

14 

15# ============================================================================= 

16# Resilience - Retry Configuration 

17# ============================================================================= 

18 

19# Default retry attempts for operations that can be retried 

20DEFAULT_RETRY_ATTEMPTS: int = 4 

21 

22# Initial delay between retry attempts in seconds 

23DEFAULT_INITIAL_DELAY: float = 1.0 

24 

25# Maximum delay between retry attempts in seconds 

26DEFAULT_MAX_DELAY: float = 60.0 

27 

28# Exponential backoff base multiplier 

29DEFAULT_EXPONENTIAL_BASE: float = 2.0 

30 

31# Jitter factors for randomizing delays to avoid thundering herd 

32JITTER_MIN_FACTOR: float = 0.5 # 50% minimum delay multiplier 

33JITTER_MAX_FACTOR: float = 1.0 # 100% maximum delay multiplier (adds to min for 150% total) 

34 

35# ============================================================================= 

36# Resilience - Circuit Breaker Configuration 

37# ============================================================================= 

38 

39# Number of consecutive failures before circuit breaker opens 

40DEFAULT_FAILURE_THRESHOLD: int = 5 

41 

42# Time in seconds before attempting to close an open circuit breaker 

43DEFAULT_RECOVERY_TIMEOUT: float = 60.0 

44 

45# Number of consecutive successes required to close circuit breaker 

46DEFAULT_SUCCESS_THRESHOLD: int = 2 

47 

48# ============================================================================= 

49# Network and API Configuration 

50# ============================================================================= 

51 

52# Default timeout for API calls in seconds 

53DEFAULT_API_TIMEOUT: float = 1.0 

54 

55# Default timeout for data processor operations in seconds 

56DEFAULT_DATA_PROCESSOR_TIMEOUT: int = 30 

57 

58# Default timeout for telemetry flush operations in seconds 

59DEFAULT_TELEMETRY_FLUSH_TIMEOUT: float = 2.0 

60 

61# Minimum delay for simulation operations in seconds 

62SIMULATION_DELAY_MIN: float = 0.1 

63 

64# Multiplier for timeout when simulating failures (120% of timeout) 

65TIMEOUT_FAILURE_MULTIPLIER: float = 1.2 

66 

67# Multiplier for timeout when simulating successes (80% of timeout) 

68TIMEOUT_SUCCESS_MULTIPLIER: float = 0.8 

69 

70# ============================================================================= 

71# Feature Flags and Percentage Configuration 

72# ============================================================================= 

73 

74# Default failure rate for operations (30%) 

75DEFAULT_FAILURE_RATE: float = 0.3 

76 

77# Minimum percentage value for feature flag rollouts 

78PERCENTAGE_MIN: int = 0 

79 

80# Maximum percentage value for feature flag rollouts 

81PERCENTAGE_MAX: int = 100 

82 

83# Default telemetry sampling rate (10% of operations) 

84TELEMETRY_SAMPLE_RATE: float = 0.1 

85 

86# ============================================================================= 

87# Hash and Identifier Configuration 

88# ============================================================================= 

89 

90# Length of hash prefix used for feature flag bucketing 

91HASH_PREFIX_LENGTH: int = 8 

92 

93# Maximum value for random user ID generation 

94USER_ID_RANDOM_MAX: int = 10**9 

95 

96# ============================================================================= 

97# CLI and User Interface Configuration 

98# ============================================================================= 

99 

100# Initial delay for CLI resilient operations in seconds 

101CLI_RESILIENT_INITIAL_DELAY: float = 0.5 

102 

103# Recovery timeout for CLI circuit breaker in seconds 

104CLI_RESILIENT_RECOVERY_TIMEOUT: int = 30 

105 

106# Length of separator lines in CLI output 

107CLI_SEPARATOR_LENGTH: int = 60 

108 

109# ============================================================================= 

110# Data Processing Configuration 

111# ============================================================================= 

112 

113# Default chunk size for batch processing operations 

114DEFAULT_BATCH_CHUNK_SIZE: int = 100 

115 

116# Indentation level for JSON formatting 

117JSON_INDENT: int = 2