Clients - http : CircuitBreakerClient

A Circuit Breaker implementation which can be used to gracefully handle network failures.

Constructor

__init

(string url, ClientConfiguration config, CircuitBreakerInferredConfig circuitBreakerInferredConfig, HttpClient httpClient, CircuitHealth circuitHealth)

  • url string
  • The URL of the target service

  • config ClientConfiguration
  • The configurations of the client endpoint associated with this CircuitBreaker instance

  • httpClient HttpClient
  • The underlying HttpActions instance which will be making the actual network calls

Methods

post

The POST remote function implementation of the Circuit Breaker. This wraps the post() function of the underlying HTTP remote functions provider.

head

The HEAD remote function implementation of the Circuit Breaker. This wraps the head() function of the underlying HTTP remote functions provider.

put

The PUT remote function implementation of the Circuit Breaker. This wraps the put() function of the underlying HTTP remote functions provider.

execute

This wraps the post() function of the underlying HTTP remote functions provider. The execute() function can be used to invoke an HTTP call with the given HTTP verb.

patch

The PATCH remote function implementation of the Circuit Breaker. This wraps the patch() function of the underlying HTTP remote functions provider.

delete

The DELETE remote function implementation of the Circuit Breaker. This wraps the delete() function of the underlying HTTP remote functions provider.

get

The GET remote function implementation of the Circuit Breaker. This wraps the get() function of the underlying HTTP remote functions provider.

options

The OPTIONS remote function implementation of the Circuit Breaker. This wraps the options() function of the underlying HTTP remote functions provider.

forward

This wraps the forward() function of the underlying HTTP remote functions provider. The Forward remote function can be used to forward an incoming request to an upstream service as it is.

submit

Submits an HTTP request to a service with the specified HTTP verb. The submit() function does not give out a Response as the result, rather it returns an HttpFuture which can be used to do further interactions with the endpoint.

getResponse

Retrieves the Response for a previously submitted request.

hasPromise

Circuit breaking not supported. Defaults to the hasPromise() function of the underlying HTTP remote functions provider.

getNextPromise

Retrieves the next available PushPromise for a previously submitted request.

getPromisedResponse

Retrieves the promised server push Response message.

rejectPromise

Circuit breaking not supported. Defaults to the rejectPromise() function of the underlying HTTP remote functions provider.

forceClose

Force the circuit into a closed state in which it will allow requests regardless of the error percentage until the failure threshold exceeds.

forceOpen

Force the circuit into a open state in which it will suspend all requests until resetTimeInMillis interval exceeds.

getCurrentState

Provides CircuitState of the circuit breaker.

Fields

  • url string
  • The URL of the target service

  • config ClientConfiguration
  • The configurations of the client endpoint associated with this CircuitBreaker instance

  • httpClient HttpClient
  • The underlying HttpActions instance which will be making the actual network calls

  • currentCircuitState CircuitState CB_CLOSED_STATE
  • The current state the circuit is in

post

(string path, RequestMessage message)

returns Response | ClientError

The POST remote function implementation of the Circuit Breaker. This wraps the post() function of the underlying HTTP remote functions provider.

Parameters

  • path string
  • Resource path

  • message RequestMessage
  • A Request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | ClientError)
  • The response for the request or an http:ClientError if failed to establish communication with the upstream server

The HEAD remote function implementation of the Circuit Breaker. This wraps the head() function of the underlying HTTP remote functions provider.

Parameters

  • path string
  • Resource path

  • message RequestMessage (default ())
  • A Request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | ClientError)
  • The response for the request or an http:ClientError if failed to establish communication with the upstream server

put

(string path, RequestMessage message)

returns Response | ClientError

The PUT remote function implementation of the Circuit Breaker. This wraps the put() function of the underlying HTTP remote functions provider.

Parameters

  • path string
  • Resource path

  • message RequestMessage
  • A Request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | ClientError)
  • The response for the request or an http:ClientError if failed to establish communication with the upstream server

execute

(string httpVerb, string path, RequestMessage message)

returns Response | ClientError

This wraps the post() function of the underlying HTTP remote functions provider. The execute() function can be used to invoke an HTTP call with the given HTTP verb.

Parameters

  • httpVerb string
  • HTTP verb to be used for the request

  • path string
  • Resource path

  • message RequestMessage
  • A Request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | ClientError)
  • The response for the request or an http:ClientError if failed to establish communication with the upstream server

patch

(string path, RequestMessage message)

returns Response | ClientError

The PATCH remote function implementation of the Circuit Breaker. This wraps the patch() function of the underlying HTTP remote functions provider.

Parameters

  • path string
  • Resource path

  • message RequestMessage
  • A Request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | ClientError)
  • The response for the request or an http:ClientError if failed to establish communication with the upstream server

delete

(string path, RequestMessage message)

returns Response | ClientError

The DELETE remote function implementation of the Circuit Breaker. This wraps the delete() function of the underlying HTTP remote functions provider.

Parameters

  • path string
  • Resource path

  • message RequestMessage (default ())
  • A Request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | ClientError)
  • The response for the request or an http:ClientError if failed to establish communication with the upstream server

get

(string path, RequestMessage message)

returns Response | ClientError

The GET remote function implementation of the Circuit Breaker. This wraps the get() function of the underlying HTTP remote functions provider.

Parameters

  • path string
  • Resource path

  • message RequestMessage (default ())
  • An optional HTTP request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | ClientError)
  • The response for the request or an http:ClientError if failed to establish communication with the upstream server

options

(string path, RequestMessage message)

returns Response | ClientError

The OPTIONS remote function implementation of the Circuit Breaker. This wraps the options() function of the underlying HTTP remote functions provider.

Parameters

  • path string
  • Resource path

  • message RequestMessage (default ())
  • An optional HTTP Request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | ClientError)
  • The response for the request or an http:ClientError if failed to establish communication with the upstream server

forward

(string path, Request request)

returns Response | ClientError

This wraps the forward() function of the underlying HTTP remote functions provider. The Forward remote function can be used to forward an incoming request to an upstream service as it is.

Parameters

  • path string
  • Resource path

  • Return Type

    (Response | ClientError)
  • The response for the request or an http:ClientError if failed to establish communication with the upstream server

submit

(string httpVerb, string path, RequestMessage message)

returns HttpFuture | ClientError

Submits an HTTP request to a service with the specified HTTP verb. The submit() function does not give out a Response as the result, rather it returns an HttpFuture which can be used to do further interactions with the endpoint.

Parameters

  • httpVerb string
  • The HTTP verb value

  • path string
  • The resource path

  • message RequestMessage
  • An HTTP outbound request message or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (HttpFuture | ClientError)
  • An HttpFuture that represents an asynchronous service invocation, or an http:ClientError if the submission fails

getResponse

(HttpFuture httpFuture)

returns Response | ClientError

Retrieves the Response for a previously submitted request.

Parameters

  • httpFuture HttpFuture
  • The HttpFuture related to a previous asynchronous invocation

  • Return Type

    (Response | ClientError)
  • An HTTP response message, or an http:ClientError if the invocation fails

hasPromise

(HttpFuture httpFuture)

returns boolean

Circuit breaking not supported. Defaults to the hasPromise() function of the underlying HTTP remote functions provider.

Parameters

  • httpFuture HttpFuture
  • The HttpFuture relates to a previous asynchronous invocation

  • Return Type

    (boolean)
  • A boolean that represents whether a PushPromise exists

getNextPromise

(HttpFuture httpFuture)

returns PushPromise | ClientError

Retrieves the next available PushPromise for a previously submitted request.

Parameters

  • httpFuture HttpFuture
  • The HttpFuture relates to a previous asynchronous invocation

  • Return Type

    (PushPromise | ClientError)
  • An HTTP PushPromise message, or an http:ClientError if the invocation fails

getPromisedResponse

(PushPromise promise)

returns Response | ClientError

Retrieves the promised server push Response message.

Parameters

  • Return Type

    (Response | ClientError)
  • A promised HTTP Response message, or an http:ClientError if the invocation fails

rejectPromise

Circuit breaking not supported. Defaults to the rejectPromise() function of the underlying HTTP remote functions provider.

Parameters

forceClose

Force the circuit into a closed state in which it will allow requests regardless of the error percentage until the failure threshold exceeds.

forceOpen

Force the circuit into a open state in which it will suspend all requests until resetTimeInMillis interval exceeds.

getCurrentState

()

returns CircuitState

Provides CircuitState of the circuit breaker.

  • Return Type

    (CircuitState)
  • The current CircuitState of circuit breaker