command_properties.py 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. from __future__ import absolute_import
  2. import logging
  3. log = logging.getLogger(__name__)
  4. class CommandProperties(object):
  5. """ Properties for instances of :class:`hystrix.command.Command`
  6. """
  7. # Default values
  8. # 10000 = 10 seconds (and default of 10 buckets so each bucket is 1
  9. # second)
  10. default_metrics_rolling_statistical_window = 10000
  11. # 10 buckets in a 10 second window so each bucket is 1 second
  12. default_metrics_rolling_statistical_window_buckets = 10
  13. # 20 requests in 10 seconds must occur before statistics matter
  14. default_circuit_breaker_request_volume_threshold = 20
  15. # 5000 = 5 seconds that we will sleep before trying again after tripping
  16. # the circuit
  17. default_circuit_breaker_sleep_window_in_milliseconds = 5000
  18. # 50 = if 50%+ of requests in 10 seconds are failures or latent when we
  19. # will trip the circuit
  20. default_circuit_breaker_error_threshold_percentage = 50
  21. # If ``False`` we want to allow traffic.
  22. default_circuit_breaker_force_open = False
  23. # If ``False`` ignore errors
  24. default_circuit_breaker_force_closed = False
  25. # 1000 = 1 second timeout
  26. default_execution_timeout_in_milliseconds = 1000
  27. # Whether a command should be executed in a separate thread or not
  28. default_execution_isolation_strategy = 0
  29. # Wheather a thread should interrupt on timeout.
  30. default_execution_isolation_thread_interrupt_on_timeout = True
  31. # Wheather rolling percentile should be enabled.
  32. default_metrics_rolling_percentile_enabled = True
  33. # Wheather request cache should be enabled
  34. default_request_cache_enabled = True
  35. # Default fallback isolation semaphore max concurrent requests
  36. default_fallback_isolation_semaphore_max_concurrent_requests = 10
  37. # Wheather fallback should be enabled
  38. default_fallback_enabled = True
  39. # Default execution isolation semaphore max concurrent requests
  40. default_execution_isolation_semaphore_max_concurrent_requests = 10
  41. # Wheather request log should be enabled
  42. default_request_log_enabled = True
  43. # Wheather circuit breaker should be enabled
  44. default_circuit_breaker_enabled = True
  45. # Default to 1 minute for
  46. # :class:`hystrix.rolling_percentile._rolling_percentile`
  47. default_metrics_rolling_percentile_window = 60000
  48. # Default to 6 buckets (10 seconds each in 60 second window)
  49. default_metrics_rolling_percentile_window_buckets = 6
  50. # Default to 100 values max per bucket
  51. default_metrics_rolling_percentile_bucket_size = 100
  52. # Default to 500ms as max frequency between allowing snapshots of health
  53. # (error percentage etc)
  54. default_metrics_health_snapshot_interval_in_milliseconds = 500
  55. def __init__(self, command_key, setter, property_prefix=None):
  56. self.command_key = command_key
  57. self.property_prefix = property_prefix
  58. # Whether circuit breaker should be enabled
  59. self._circuit_breaker_enabled = \
  60. self._property(
  61. self.property_prefix, self.command_key,
  62. 'circuit_breaker.enabled',
  63. self.default_circuit_breaker_enabled,
  64. setter.circuit_breaker_enabled())
  65. # Number of requests that must be made within a statisticalWindow
  66. # before open/close decisions are made using stats
  67. self._circuit_breaker_request_volume_threshold = \
  68. self._property(
  69. self.property_prefix, self.command_key,
  70. 'circuit_breaker.request_volume_threshold',
  71. self.default_circuit_breaker_request_volume_threshold,
  72. setter.circuit_breaker_request_volume_threshold())
  73. # Milliseconds after tripping circuit before allowing retry
  74. self._circuit_breaker_sleep_window_in_milliseconds = \
  75. self._property(
  76. self.property_prefix, self.command_key,
  77. 'circuit_breaker.sleep_window_in_milliseconds',
  78. self.default_circuit_breaker_sleep_window_in_milliseconds,
  79. setter.circuit_breaker_sleep_window_in_milliseconds())
  80. # % of 'marks' that must be failed to trip the circuit
  81. self._circuit_breaker_error_threshold_percentage = \
  82. self._property(
  83. self.property_prefix, self.command_key,
  84. 'circuit_breaker.error_threshold_percentage',
  85. self.default_circuit_breaker_error_threshold_percentage,
  86. setter.circuit_breaker_error_threshold_percentage())
  87. # A property to allow forcing the circuit open (stopping all requests)
  88. self._circuit_breaker_force_open = \
  89. self._property(
  90. self.property_prefix, self.command_key,
  91. 'circuit_breaker.force_open',
  92. self.default_circuit_breaker_force_open,
  93. setter.circuit_breaker_force_open())
  94. # a property to allow ignoring errors and therefore never trip 'open'
  95. # (ie. allow all traffic through)
  96. self._circuit_breaker_force_closed = \
  97. self._property(
  98. self.property_prefix, self.command_key,
  99. 'circuit_breaker.force_closed',
  100. self.default_circuit_breaker_force_closed,
  101. setter.circuit_breaker_force_closed())
  102. # Whether a command should be executed in a separate thread or not
  103. self._execution_isolation_strategy = \
  104. self._property(
  105. self.property_prefix, self.command_key,
  106. 'execution.isolation.strategy',
  107. self.default_execution_isolation_strategy,
  108. setter.execution_isolation_strategy())
  109. # Timeout value in milliseconds for a command
  110. self._execution_timeout_in_milliseconds = \
  111. self._property(
  112. self.property_prefix, self.command_key,
  113. 'execution.isolation.thread.timeout_in_milliseconds',
  114. self.default_execution_timeout_in_milliseconds,
  115. setter.execution_timeout_in_milliseconds())
  116. # execution_isolation_thread_pool_key_override
  117. # Number of permits for execution semaphore
  118. self._execution_isolation_semaphore_max_concurrent_requests = \
  119. self._property(
  120. self.property_prefix, self.command_key,
  121. 'execution.isolation.semaphore.max_concurrent_requests',
  122. self.default_execution_isolation_semaphore_max_concurrent_requests,
  123. setter.execution_isolation_semaphore_max_concurrent_requests())
  124. # Number of permits for fallback semaphore
  125. self._fallback_isolation_semaphore_max_concurrent_requests = \
  126. self._property(
  127. self.property_prefix, self.command_key,
  128. 'fallback.isolation.semaphore.max_concurrent_requests',
  129. self.default_fallback_isolation_semaphore_max_concurrent_requests,
  130. setter.fallback_isolation_semaphore_max_concurrent_requests())
  131. # Whether fallback should be attempted
  132. self._fallback_enabled = \
  133. self._property(
  134. self.property_prefix, self.command_key, 'fallback.enabled',
  135. self.default_fallback_enabled,
  136. setter.fallback_enabled())
  137. # Whether an underlying Future/Thread
  138. # (when runInSeparateThread == true) should be interrupted after a
  139. # timeout
  140. self._execution_isolation_thread_interrupt_on_timeout = \
  141. self._property(
  142. self.property_prefix, self.command_key,
  143. 'execution.isolation.thread.interrupt_on_timeout',
  144. self.default_execution_isolation_thread_interrupt_on_timeout,
  145. setter.execution_isolation_thread_interrupt_on_timeout())
  146. # Milliseconds back that will be tracked
  147. self._metrics_rolling_statistical_window_in_milliseconds = \
  148. self._property(
  149. self.property_prefix, self.command_key,
  150. 'metrics.rolling_stats.time_in_milliseconds',
  151. self.default_metrics_rolling_statistical_window,
  152. setter.metrics_rolling_statistical_window_in_milliseconds())
  153. # number of buckets in the statisticalWindow
  154. self._metrics_rolling_statistical_window_buckets = \
  155. self._property(
  156. self.property_prefix, self.command_key,
  157. 'metrics.rolling_stats.num_buckets',
  158. self.default_metrics_rolling_statistical_window_buckets,
  159. setter.metrics_rolling_statistical_window_buckets())
  160. # Whether monitoring should be enabled (SLA and Tracers)
  161. self._metrics_rolling_percentile_enabled = \
  162. self._property(
  163. self.property_prefix,
  164. self.command_key, 'metrics.rolling_percentile.enabled',
  165. self.default_metrics_rolling_percentile_enabled,
  166. setter.metrics_rolling_percentile_enabled())
  167. # Number of milliseconds that will be tracked in
  168. # :class:`hystrix.rolling_percentile.RollingPercentile`
  169. self._metrics_rolling_percentile_window_in_milliseconds = \
  170. self._property(
  171. self.property_prefix, self.command_key,
  172. 'metrics.rolling_percentile.time_in_milliseconds',
  173. self.default_metrics_rolling_percentile_window,
  174. setter.metrics_rolling_percentile_window_in_milliseconds())
  175. # Number of buckets percentileWindow will be divided into
  176. self._metrics_rolling_percentile_window_buckets = \
  177. self._property(
  178. self.property_prefix, self.command_key,
  179. 'metrics.rolling_percentile.num_buckets',
  180. self.default_metrics_rolling_percentile_window_buckets,
  181. setter.metrics_rolling_percentile_window_buckets())
  182. # How many values will be stored in each
  183. # :attr:`percentile_window_bucket`
  184. self._metrics_rolling_percentile_bucket_size = \
  185. self._property(
  186. self.property_prefix, self.command_key,
  187. 'metrics.rolling_percentile.bucket_size',
  188. self.default_metrics_rolling_percentile_bucket_size,
  189. setter.metrics_rolling_percentile_bucket_size())
  190. # Time between health snapshots
  191. self._metrics_health_snapshot_interval_in_milliseconds = \
  192. self._property(
  193. self.property_prefix, self.command_key,
  194. 'metrics.health_snapshot.interval_in_milliseconds',
  195. self.default_metrics_health_snapshot_interval_in_milliseconds,
  196. setter.metrics_health_snapshot_interval_in_milliseconds())
  197. # Whether command request logging is enabled
  198. self._request_log_enabled = \
  199. self._property(
  200. property_prefix, self.command_key, 'request_log.enabled',
  201. self.default_request_log_enabled,
  202. setter.request_log_enabled())
  203. # Whether request caching is enabled
  204. self._request_cache_enabled = \
  205. self._property(
  206. self.property_prefix, self.command_key,
  207. 'request_cache.enabled',
  208. self.default_request_cache_enabled,
  209. setter.request_cache_enabled())
  210. # threadpool doesn't have a global override, only instance level
  211. # makes sense
  212. # self.execution_isolation_thread_pool_key_override = \
  213. # as__property(
  214. # DynamicStringProperty(
  215. # '{`.command.{`.thread_pool_key_override'.format(
  216. # self.property_prefix, self.command_key), None))
  217. def circuit_breaker_enabled(self):
  218. """ Whether to use a :class:`hystrix.CircuitBreaker` or not. If false no
  219. circuit-breaker logic will be used and all requests permitted.
  220. This is similar in effect to :class:`#circuitBreakerForceClosed()`
  221. except that continues tracking metrics and knowing whether it should be
  222. open/closed, this property results in not even instantiating a
  223. circuit-breaker.
  224. Returns:
  225. bool: ``True`` or ``False``
  226. """
  227. return self._circuit_breaker_enabled
  228. def circuit_breaker_error_threshold_percentage(self):
  229. """ Error percentage threshold (as whole number such as 50) at which
  230. point the circuit breaker will trip open and reject requests.
  231. It will stay tripped for the duration defined in
  232. :class:`#circuitBreakerSleepWindowInMilliseconds()`;
  233. The error percentage this is compared against comes from
  234. :class:`hystrix.CommandMetrics#getHealthCounts()`.
  235. Returns:
  236. int: Error percentage
  237. """
  238. return self._circuit_breaker_error_threshold_percentage
  239. def circuit_breaker_force_closed(self):
  240. """ If true the :class:`hystrix.CircuitBreaker#allowRequest()` will
  241. always return true to allow requests regardless of the error percentage
  242. from :class:`hystrix.CommandMetrics#getHealthCounts()`.
  243. The :class:`#circuitBreakerForceOpen()` property takes precedence so
  244. if it set to true this property does nothing.
  245. Returns:
  246. bool: ``True`` or ``False``
  247. """
  248. return self._circuit_breaker_force_closed
  249. def circuit_breaker_force_open(self):
  250. """ If true the :class:`hystrix.CircuitBreaker#allowRequest()` will
  251. always return false, causing the circuit to be open (tripped) and
  252. reject all requests.
  253. This property takes precedence over
  254. :class:`#circuitBreakerForceClosed()`;
  255. Returns:
  256. bool: ``True`` or ``False``
  257. """
  258. return self._circuit_breaker_force_open
  259. def circuit_breaker_request_volume_threshold(self):
  260. """ Minimum number of requests in the
  261. :class:`#metricsRollingStatisticalWindowInMilliseconds()` that must
  262. exist before the :class:`hystrix.CircuitBreaker` will trip.
  263. If below this number the circuit will not trip regardless of error
  264. percentage.
  265. Returns:
  266. int: Number of request
  267. """
  268. return self._circuit_breaker_request_volume_threshold
  269. def circuit_breaker_sleep_window_in_milliseconds(self):
  270. """ The time in milliseconds after a :class:`hystrix.CircuitBreaker`
  271. trips open that it should wait before trying requests again.
  272. Returns:
  273. int: Time in milliseconds
  274. """
  275. return self._circuit_breaker_sleep_window_in_milliseconds
  276. def execution_isolation_semaphore_max_concurrent_requests(self):
  277. """ Number of concurrent requests permitted to
  278. :class:`hystrix.Command#run()`. Requests beyond the concurrent limit
  279. will be rejected.
  280. Applicable only when:
  281. :class:`#executionIsolationStrategy()` == SEMAPHORE.
  282. Returns:
  283. int: Number of concurrent requests
  284. """
  285. return self._execution_isolation_semaphore_max_concurrent_requests
  286. def execution_isolation_strategy(self):
  287. """ What isolation strategy :class:`hystrix.Command#run()` will be
  288. executed with.
  289. If :class:`ExecutionIsolationStrategy#THREAD` then it will be executed
  290. on a separate thread and concurrent requests limited by the number of
  291. threads in the thread-pool.
  292. If :class:`ExecutionIsolationStrategy#SEMAPHORE` then it will be
  293. executed on the calling thread and concurrent requests limited by the
  294. semaphore count.
  295. Returns:
  296. bool: ``True`` or ``False``
  297. """
  298. return self._execution_isolation_strategy
  299. def execution_isolation_thread_interrupt_on_timeout(self):
  300. """ Whether the execution thread should attempt an interrupt
  301. (using :class:`Future#cancel`) when a thread times out.
  302. Applicable only when :class:`#executionIsolationStrategy()` == THREAD.
  303. Returns:
  304. bool: ``True`` or ``False``
  305. """
  306. return self._execution_isolation_thread_interrupt_on_timeout
  307. def execution_timeout_in_milliseconds(self):
  308. """ Time in milliseconds at which point the command will timeout and
  309. halt execution.
  310. If :class:`#executionIsolationThreadInterruptOnTimeout` == true and the
  311. command is thread-isolated, the executing thread will be interrupted.
  312. If the command is semaphore-isolated and a
  313. :class:`hystrix.ObservableCommand`, that command will get unsubscribed.
  314. Returns:
  315. int: Time in milliseconds
  316. """
  317. return self._execution_timeout_in_milliseconds
  318. def fallback_isolation_semaphore_max_concurrent_requests(self):
  319. """ Number of concurrent requests permitted to
  320. :class:`hystrix.Command#getFallback()`. Requests beyond the concurrent
  321. limit will fail-fast and not attempt retrieving a fallback.
  322. Returns:
  323. int: Number of concurrent requests
  324. """
  325. return self._fallback_isolation_semaphore_max_concurrent_requests
  326. def fallback_enabled(self):
  327. """ Whether :class:`hystrix.Command#getFallback()` should be attempted
  328. when failure occurs.
  329. Returns:
  330. bool: ``True`` or ``False``
  331. """
  332. return self._fallback_enabled
  333. def metrics_health_snapshot_interval_in_milliseconds(self):
  334. """ Time in milliseconds to wait between allowing health snapshots to
  335. be taken that calculate success and error percentages and affect
  336. :class:`hystrix.CircuitBreaker#isOpen()` status.
  337. On high-volume circuits the continual calculation of error percentage
  338. can become CPU intensive thus this controls how often it is
  339. calculated.
  340. Returns:
  341. int: Time in milliseconds
  342. """
  343. return self._metrics_health_snapshot_interval_in_milliseconds
  344. def metrics_rolling_percentile_bucket_size(self):
  345. """ Maximum number of values stored in each bucket of the rolling
  346. percentile. This is passed into :class:`hystrix.RollingPercentile`
  347. inside :class:`hystrix.CommandMetrics`.
  348. Returns:
  349. int: Maximum number of values stored in each bucket
  350. """
  351. return self._metrics_rolling_percentile_bucket_size
  352. def metrics_rolling_percentile_enabled(self):
  353. """ Whether percentile metrics should be captured using
  354. :class:`hystrix.RollingPercentile` inside
  355. :class:`hystrix.CommandMetrics`.
  356. Returns:
  357. bool: ``True`` or ``False``
  358. """
  359. return self._metrics_rolling_percentile_enabled
  360. def metrics_rolling_percentile_window_in_milliseconds(self):
  361. """ Duration of percentile rolling window in milliseconds. This is
  362. passed into :class:`hystrix.RollingPercentile` inside
  363. :class:`hystrix.CommandMetrics`.
  364. Returns:
  365. int: Milliseconds
  366. """
  367. return self._metrics_rolling_percentile_window_in_milliseconds
  368. def metrics_rolling_percentile_window_buckets(self):
  369. """ Number of buckets the rolling percentile window is broken into.
  370. This is passed into :class:`hystrix.RollingPercentile` inside
  371. :class:`hystrix.CommandMetrics`.
  372. Returns:
  373. int: Buckets
  374. """
  375. return self._metrics_rolling_percentile_window_buckets
  376. def metrics_rolling_statistical_window_in_milliseconds(self):
  377. """ Duration of statistical rolling window in milliseconds. This is
  378. passed into :class:`hystrix.RollingNumber` inside
  379. :class:`hystrix.CommandMetrics`.
  380. Returns:
  381. int: Milliseconds
  382. """
  383. return self._metrics_rolling_statistical_window_in_milliseconds
  384. def metrics_rolling_statistical_window_buckets(self):
  385. """ Number of buckets the rolling statistical window is broken into.
  386. This is passed into :class:`hystrix.RollingNumber` inside
  387. :class:`hystrix.CommandMetrics`.
  388. Returns:
  389. int: Buckets
  390. """
  391. return self._metrics_rolling_statistical_window_buckets
  392. def request_cache_enabled(self):
  393. """ Whether :class:`hystrix.Command.getCacheKey()` should be used with
  394. :class:`hystrix.RequestCache` to provide de-duplication functionality
  395. via request-scoped caching.
  396. Returns:
  397. bool: ``True`` or ``False``
  398. """
  399. return self._request_cache_enabled
  400. def request_log_enabled(self):
  401. """ Whether :class:`hystrix.command.Command` execution and events
  402. should be logged to :class:`hystrix.request.RequestLog`.
  403. Returns:
  404. bool: ``True`` or ``False``
  405. """
  406. return self._request_log_enabled
  407. def _property(self, property_prefix, command_key, instance_property,
  408. default_value, setter_override_value=None):
  409. """ Get property from a networked plugin
  410. """
  411. # The setter override should take precedence over default_value
  412. if setter_override_value is not None:
  413. return setter_override_value
  414. else:
  415. return default_value
  416. @classmethod
  417. def setter(klass):
  418. """ Factory method to retrieve the default Setter """
  419. return klass.Setter()
  420. class Setter(object):
  421. """ Fluent interface that allows chained setting of properties
  422. That can be passed into a :class:`hystrix.command.Command` constructor
  423. to inject instance specific property overrides.
  424. Example::
  425. >>> CommandProperties.setter()
  426. .with_execution_timeout_in_milliseconds(100)
  427. .with_execute_command_on_separate_thread(True)
  428. """
  429. def __init__(self):
  430. self._circuit_breaker_enabled = None
  431. self._circuit_breaker_error_threshold_percentage = None
  432. self._circuit_breaker_force_closed = None
  433. self._circuit_breaker_force_open = None
  434. self._circuit_breaker_request_volume_threshold = None
  435. self._circuit_breaker_sleep_window_in_milliseconds = None
  436. self._execution_isolation_semaphore_max_concurrent_requests = None
  437. self._execution_isolation_strategy = None
  438. self._execution_isolation_thread_interrupt_on_timeout = None
  439. self._execution_timeout_in_milliseconds = None
  440. self._fallback_isolation_semaphore_max_concurrent_requests = None
  441. self._fallback_enabled = None
  442. self._metrics_health_snapshot_interval_in_milliseconds = None
  443. self._metrics_rolling_percentile_bucket_size = None
  444. self._metrics_rolling_percentile_enabled = None
  445. self._metrics_rolling_percentile_window_in_milliseconds = None
  446. self._metrics_rolling_percentile_window_buckets = None
  447. self._metrics_rolling_statistical_window_in_milliseconds = None
  448. self._metrics_rolling_statistical_window_buckets = None
  449. self._request_cache_enabled = None
  450. self._request_log_enabled = None
  451. def circuit_breaker_enabled(self):
  452. return self._circuit_breaker_enabled
  453. def circuit_breaker_error_threshold_percentage(self):
  454. return self._circuit_breaker_error_threshold_percentage
  455. def circuit_breaker_force_closed(self):
  456. return self._circuit_breaker_force_closed
  457. def circuit_breaker_force_open(self):
  458. return self._circuit_breaker_force_open
  459. def circuit_breaker_request_volume_threshold(self):
  460. return self._circuit_breaker_request_volume_threshold
  461. def circuit_breaker_sleep_window_in_milliseconds(self):
  462. return self._circuit_breaker_sleep_window_in_milliseconds
  463. def execution_isolation_semaphore_max_concurrent_requests(self):
  464. return self._execution_isolation_semaphore_max_concurrent_requests
  465. def execution_isolation_strategy(self):
  466. return self._execution_isolation_strategy
  467. def execution_isolation_thread_interrupt_on_timeout(self):
  468. return self._execution_isolation_thread_interrupt_on_timeout
  469. def execution_timeout_in_milliseconds(self):
  470. return self._execution_timeout_in_milliseconds
  471. def fallback_isolation_semaphore_max_concurrent_requests(self):
  472. return self._fallback_isolation_semaphore_max_concurrent_requests
  473. def fallback_enabled(self):
  474. return self._fallback_enabled
  475. def metrics_health_snapshot_interval_in_milliseconds(self):
  476. return self._metrics_health_snapshot_interval_in_milliseconds
  477. def metrics_rolling_percentile_bucket_size(self):
  478. return self._metrics_rolling_percentile_bucket_size
  479. def metrics_rolling_percentile_enabled(self):
  480. return self._metrics_rolling_percentile_enabled
  481. def metrics_rolling_percentile_window_in_milliseconds(self):
  482. return self._metrics_rolling_percentile_window_in_milliseconds
  483. def metrics_rolling_percentile_window_buckets(self):
  484. return self._metrics_rolling_percentile_window_buckets
  485. def metrics_rolling_statistical_window_in_milliseconds(self):
  486. return self._metrics_rolling_statistical_window_in_milliseconds
  487. def metrics_rolling_statistical_window_buckets(self):
  488. return self._metrics_rolling_statistical_window_buckets
  489. def request_cache_enabled(self):
  490. return self._request_cache_enabled
  491. def request_log_enabled(self):
  492. return self._request_log_enabled
  493. def with_circuit_breaker_enabled(self, value):
  494. self._circuit_breaker_enabled = value
  495. return self
  496. def with_circuit_breaker_error_threshold_percentage(self, value):
  497. self._circuit_breaker_error_threshold_percentage = value
  498. return self
  499. def with_circuit_breaker_force_closed(self, value):
  500. self._circuit_breaker_force_closed = value
  501. return self
  502. def with_circuit_breaker_force_open(self, value):
  503. self._circuit_breaker_force_open = value
  504. return self
  505. def with_circuit_breaker_request_volume_threshold(self, value):
  506. self._circuit_breaker_request_volume_threshold = value
  507. return self
  508. def with_circuit_breaker_sleep_window_in_milliseconds(self, value):
  509. self._circuit_breaker_sleep_window_in_milliseconds = value
  510. return self
  511. def with_execution_isolation_semaphore_max_concurrent_requests(self, value):
  512. self._execution_isolation_semaphore_max_concurrent_requests = value
  513. return self
  514. def with_execution_isolation_strategy(self, value):
  515. self._execution_isolation_strategy = value
  516. return self
  517. def with_execution_isolation_thread_interrupt_on_timeout(self, value):
  518. self._execution_isolation_thread_interrupt_on_timeout = value
  519. return self
  520. def with_execution_timeout_in_milliseconds(self, value):
  521. self._execution_timeout_in_milliseconds = value
  522. return self
  523. def with_fallback_isolation_semaphore_max_concurrent_requests(self, value):
  524. self._fallback_isolation_semaphore_max_concurrent_requests = value
  525. return self
  526. def with_fallback_enabled(self, value):
  527. self._fallback_enabled = value
  528. return self
  529. def with_metrics_health_snapshot_interval_in_milliseconds(self, value):
  530. self._metrics_health_snapshot_interval_in_milliseconds = value
  531. return self
  532. def with_metrics_rolling_percentile_bucket_size(self, value):
  533. self._metrics_rolling_percentile_bucket_size = value
  534. return self
  535. def with_metrics_rolling_percentile_enabled(self, value):
  536. self._metrics_rolling_percentile_enabled = value
  537. return self
  538. def with_metrics_rolling_percentile_window_in_milliseconds(self, value):
  539. self._metrics_rolling_percentile_window_in_milliseconds = value
  540. return self
  541. def with_metrics_rolling_percentile_window_buckets(self, value):
  542. self._metrics_rolling_percentile_window_buckets = value
  543. return self
  544. def with_metrics_rolling_statistical_window_in_milliseconds(self, value):
  545. self._metrics_rolling_statistical_window_in_milliseconds = value
  546. return self
  547. def with_metrics_rolling_statistical_window_buckets(self, value):
  548. self._metrics_rolling_statistical_window_buckets = value
  549. return self
  550. def with_request_cache_enabled(self, value):
  551. self._request_cache_enabled = value
  552. return self
  553. def with_request_log_enabled(self, value):
  554. self._request_log_enabled = value
  555. return self