ballerina.net.http.resiliency package
public struct FailoverConfig
Represents Failover connector retry configuration.
Field Name | Data Type | Description | Default Value |
---|---|---|---|
failoverCodes | int[] | Array of http response status codes which required failover the requests. | |
interval | int | Failover delay interval in millisecond. |
public struct FailoverConnectorError
Represents an error occurred in an action of the Failover connector.
Field Name | Data Type | Description | Default Value |
---|---|---|---|
message | string | An error message explaining about the error. | |
cause | error | The error that caused HttpConnectorError to get thrown. | |
statusCode | int | HTTP status code of the FailoverConnectorError. | |
httpConnectorError | HttpConnectorError[] | Array of HttpConnectorError error occurred at each endpoint. |
public struct LoadBalanceConnectorError
Represents an error occurred in an action of the Load Balance connector.
Field Name | Data Type | Description | Default Value |
---|---|---|---|
message | string | An error message explaining about the error. | |
cause | error | The error that caused HttpConnectorError to get thrown. | |
statusCode | int | HTTP status code of the LoadBalanceConnectorError. | |
httpConnectorError | HttpConnectorError[] | Array of HttpConnectorError error occurred at each endpoint. |
public function invokeEndpoint ( string path , OutRequest outRequest , InRequest inRequest , HttpOperation requestAction , HttpClient httpClient ) ( InResponse , HttpConnectorError )
Parameter Name | Data Type | Description |
---|---|---|
path | string | |
outRequest | OutRequest | |
inRequest | InRequest | |
requestAction | HttpOperation | |
httpClient | HttpClient |
Return Variable | Data Type | Description |
---|---|---|
InResponse | ||
HttpConnectorError |
public connector CircuitBreaker ( HttpClient httpClient , float failureThreshold , int resetTimeout )
A Circuit Breaker implementation for to be used with the HTTP client connector to gracefully handle network errors
Parameter Name | Data Type | Description |
---|---|---|
httpClient | HttpClient | The HTTP client connector to be wrapped with the circuit breaker |
failureThreshold | float | The threshold for request failures. When this threshold is crossed, the circuit will trip. The threshold should be a value between 0 and 1. |
resetTimeout | int | The time period to wait before attempting to make another request to the upstream service |
Actions:
-
< CircuitBreaker > delete ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The DELETE action implementation of the Circuit Breaker. Protects the invocation of the DELETE action of the underlying HTTP client connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< CircuitBreaker > execute ( string httpVerb , string path , OutRequest request ) ( InResponse , HttpConnectorError )
Protects the invocation of the Execute action of the underlying HTTP client connector. The Execute action can be used to invoke an HTTP call with the given HTTP verb.
Parameter Name Data Type Description httpVerb string HTTP verb to be used for the request path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< CircuitBreaker > forward ( string path , InRequest request ) ( InResponse , HttpConnectorError )
Protects the invocation of the Forward action of the underlying HTTP client connector. The Forward action can be used to forward an incoming request to an upstream service as it is.
Parameter Name Data Type Description path string Resource path request InRequest An InRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< CircuitBreaker > get ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The GET action implementation of the Circuit Breaker. Protects the invocation of the GET action of the underlying HTTP client connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< CircuitBreaker > head ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The HEAD action implementation of the Circuit Breaker. Protects the invocation of the HEAD action of the underlying HTTP client connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< CircuitBreaker > options ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The OPTIONS action implementation of the Circuit Breaker. Protects the invocation of the OPTIONS action of the underlying HTTP client connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< CircuitBreaker > patch ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The PATCH action implementation of the Circuit Breaker. Protects the invocation of the PATCH action of the underlying HTTP client connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< CircuitBreaker > post ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The POST action implementation of the Circuit Breaker. Protects the invocation of the POST action of the underlying HTTP client connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< CircuitBreaker > put ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The PUT action implementation of the Circuit Breaker. Protects the invocation of the PUT action of the underlying HTTP client connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any
public connector Failover ( HttpClient[] failoverClientsArray , FailoverConfig failoverConfig )
Failover Connector implementation to be used with the HTTP client connector to support failover.
Parameter Name | Data Type | Description |
---|---|---|
failoverClientsArray | HttpClient[] | Array of HttpClient connector to be failover. |
failoverConfig | FailoverConfig | The failoverCodes which contains InResponse Http status codes needs to be faiover. |
Actions:
-
< Failover > delete ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The DELETE action implementation of the Failover Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< Failover > execute ( string httpVerb , string path , OutRequest request ) ( InResponse , HttpConnectorError )
The EXECUTE action implementation of the Failover Connector. The Execute action can be used to invoke an HTTP call with the given HTTP verb.
Parameter Name Data Type Description httpVerb string HTTP verb to be used for the request path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< Failover > forward ( string path , InRequest request ) ( InResponse , HttpConnectorError )
The FORWARD action implementation of the Failover Connector.
Parameter Name Data Type Description path string Resource path request InRequest An InRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< Failover > get ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The GET action implementation of the Failover Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< Failover > head ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The HEAD action implementation of the Failover Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< Failover > options ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The OPTIONS action implementation of the Failover Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< Failover > patch ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The PATCH action implementation of the Failover Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< Failover > post ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The POST action implementation of the Failover Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< Failover > put ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The PUT action implementation of the Failover Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any
public connector LoadBalancer ( HttpClient[] loadBalanceClientsArray , function(HttpClient[])(HttpClient) algorithm )
LoadBalancer Connector implementation to be used with the HTTP client connector to support load balance.
Parameter Name | Data Type | Description |
---|---|---|
loadBalanceClientsArray | HttpClient[] | Array of HttpClient connector to be load balanced. |
algorithm | function(HttpClient[])(HttpClient) | Function pointer which implements the load balancing algorithm. |
Actions:
-
< LoadBalancer > delete ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The DELETE action implementation of the LoadBalancer Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< LoadBalancer > execute ( string httpVerb , string path , OutRequest request ) ( InResponse , HttpConnectorError )
The EXECUTE action implementation of the LoadBalancer Connector. The Execute action can be used to invoke an HTTP call with the given HTTP verb.
Parameter Name Data Type Description httpVerb string HTTP verb to be used for the request path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< LoadBalancer > forward ( string path , InRequest request ) ( InResponse , HttpConnectorError )
The FORWARD action implementation of the LoadBalancer Connector.
Parameter Name Data Type Description path string Resource path request InRequest An InRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< LoadBalancer > get ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The GET action implementation of the LoadBalancer Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< LoadBalancer > head ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The HEAD action implementation of the LoadBalancer Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< LoadBalancer > options ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The OPTIONS action implementation of the LoadBalancer Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< LoadBalancer > patch ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The PATCH action implementation of the LoadBalancer Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< LoadBalancer > post ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The POST action implementation of the LoadBalancer Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any -
< LoadBalancer > put ( string path , OutRequest request ) ( InResponse , HttpConnectorError )
The PUT action implementation of the Load Balance Connector.
Parameter Name Data Type Description path string Resource path request OutRequest An OutRequest struct Return Variable Data Type Description InResponse The InResponse struct HttpConnectorError Error occurred during the action invocation, if any
FORWARD
Attribute Name | Data Type | Description |
---|---|---|
FORWARD | string |
GET
Attribute Name | Data Type | Description |
---|---|---|
GET | string |
POST
Attribute Name | Data Type | Description |
---|---|---|
POST | string |
DELETE
Attribute Name | Data Type | Description |
---|---|---|
DELETE | string |
OPTIONS
Attribute Name | Data Type | Description |
---|---|---|
OPTIONS | string |
PUT
Attribute Name | Data Type | Description |
---|---|---|
PUT | string |
PATCH
Attribute Name | Data Type | Description |
---|---|---|
PATCH | string |
HEAD
Attribute Name | Data Type | Description |
---|---|---|
HEAD | string |
roundRobin
Attribute Name | Data Type | Description |
---|---|---|
roundRobin | function(HttpClient[])(HttpClient) |