Skip to content

Commit

Permalink
Container Apps Extension: Add Circuit Breaker Support for Dapr Compon…
Browse files Browse the repository at this point in the history
…ent Resiliency (#7228)
  • Loading branch information
berndverst authored Feb 20, 2024
1 parent b4cc8fa commit b921a77
Show file tree
Hide file tree
Showing 8 changed files with 3,116 additions and 1,639 deletions.
1 change: 1 addition & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Release History
===============
upcoming
++++++
* 'az containerapp env dapr-component resiliency': Add support for Dapr Component Resiliency Circuit Breakers

0.3.47
++++++
Expand Down
10 changes: 10 additions & 0 deletions src/containerapp/azext_containerapp/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@
"maxIntervalInMilliseconds": None,
}
},
"circuitBreakerPolicy": {
"consecutiveErrors": None,
"timeoutInSeconds": None,
"intervalInSeconds": None
}
},
"outboundPolicy": {
"timeoutPolicy": {
Expand All @@ -316,6 +321,11 @@
"maxIntervalInMilliseconds": None,
}
},
"circuitBreakerPolicy": {
"consecutiveErrors": None,
"timeoutInSeconds": None,
"intervalInSeconds": None
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ def load_arguments(self, _):
with self.argument_context('containerapp env dapr-component resiliency', arg_group='Inbound Timeout Policy') as c:
c.argument('in_timeout_response_in_seconds', type=int, options_list=['--in-timeout'], help='Specify the response timeout in seconds for the inbound policy. This spans between the point at which the entire request has been processed and when the response has been completely processed. This timeout includes all retries.')

with self.argument_context('containerapp env dapr-component resiliency', arg_group='Inbound Circuit Breaker Policy') as c:
c.argument('in_circuit_breaker_consecutive_errors', type=int, options_list=['--in-cb-sequential-err'], help='The number of consecutive errors before the circuit is opened.')
c.argument('in_circuit_breaker_interval', type=int, options_list=['--in-cb-interval'], help='The optional interval in seconds after which the error count resets to 0. An interval of 0 will never reset. If not specified, the timeout value will be used.')
c.argument('in_circuit_breaker_timeout', type=int, options_list=['--in-cb-timeout'], help='The interval in seconds until a retry attempt is made after the circuit is opened.')

with self.argument_context('containerapp env dapr-component resiliency', arg_group='Outbound HTTP Retry Policy') as c:
c.argument('out_http_retry_max', type=int, options_list=['--out-http-retries'], help='Specify the max number of retries for the outbound policy. Default: 3.')
c.argument('out_http_retry_delay_in_milliseconds', type=int, options_list=['--out-http-delay'], help='Specify the base interval in milliseconds between retries for the outbound policy. Default: 1000.')
Expand All @@ -158,6 +163,11 @@ def load_arguments(self, _):
with self.argument_context('containerapp env dapr-component resiliency', arg_group='Outbound Timeout Policy') as c:
c.argument('out_timeout_response_in_seconds', type=int, options_list=['--out-timeout'], help='Specify the response timeout in seconds for the outbound policy. This spans between the point at which the entire request has been processed and when the response has been completely processed. This timeout includes all retries.')

with self.argument_context('containerapp env dapr-component resiliency', arg_group='Outbound Circuit Breaker Policy') as c:
c.argument('out_circuit_breaker_consecutive_errors', type=int, options_list=['--out-cb-sequential-err'], help='The number of consecutive errors before the circuit is opened.')
c.argument('out_circuit_breaker_interval', type=int, options_list=['--out-cb-interval'], help='The optional interval in seconds after which the error count resets to 0. An interval of 0 will never reset. If not specified, the timeout value will be used.')
c.argument('out_circuit_breaker_timeout', type=int, options_list=['--out-cb-timeout'], help='The interval in seconds until a retry attempt is made after the circuit is opened.')

with self.argument_context('containerapp env dapr-component init') as c:
c.argument('statestore', help="The state store component and dev service to create.")
c.argument('pubsub', help="The pubsub component and dev service to create.")
Expand Down
16 changes: 14 additions & 2 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,13 @@ def create_dapr_component_resiliency(cmd, name, resource_group_name, dapr_compon
in_http_retry_delay_in_milliseconds=None,
out_http_retry_delay_in_milliseconds=None,
in_http_retry_interval_in_milliseconds=None,
out_http_retry_interval_in_milliseconds=None):
out_http_retry_interval_in_milliseconds=None,
in_circuit_breaker_consecutive_errors=None,
out_circuit_breaker_consecutive_errors=None,
in_circuit_breaker_interval=None,
out_circuit_breaker_interval=None,
in_circuit_breaker_timeout=None,
out_circuit_breaker_timeout=None):
raw_parameters = locals()
component_resiliency_create_decorator = DaprComponentResiliencyPreviewCreateDecorator(
cmd=cmd,
Expand All @@ -330,7 +336,13 @@ def update_dapr_component_resiliency(cmd, name, resource_group_name, dapr_compon
in_http_retry_delay_in_milliseconds=None,
out_http_retry_delay_in_milliseconds=None,
in_http_retry_interval_in_milliseconds=None,
out_http_retry_interval_in_milliseconds=None):
out_http_retry_interval_in_milliseconds=None,
in_circuit_breaker_consecutive_errors=None,
out_circuit_breaker_consecutive_errors=None,
in_circuit_breaker_interval=None,
out_circuit_breaker_interval=None,
in_circuit_breaker_timeout=None,
out_circuit_breaker_timeout=None):

raw_parameters = locals()
component_resiliency_update_decorator = DaprComponentResiliencyPreviewUpdateDecorator(
Expand Down
Loading

0 comments on commit b921a77

Please sign in to comment.