Client: FailoverClient

Isolated

An HTTP client endpoint which provides failover support over multiple HTTP clients.

Constructor

Failover caller actions which provides failover capabilities to an HTTP client endpoint.

init (*FailoverClientConfiguration failoverClientConfig)

Remote Methods

post

The POST remote function implementation of the Failover Connector.

put

The PUT remote function implementation of the Failover Connector.

patch

The PATCH remote function implementation of the Failover Connector.

delete

The DELETE remote function implementation of the Failover Connector.

head

The HEAD remote function implementation of the Failover Connector.

get

The GET remote function implementation of the Failover Connector.

options

The OPTIONS remote function implementation of the Failover Connector.

execute

Invokes an HTTP call with the specified HTTP method.

forward

Invokes an HTTP call using the incoming request's HTTP method.

submit

Submits an HTTP request to a service with the specified HTTP verb.

getResponse

Retrieves the http:Response for a previously-submitted request.

hasPromise

Checks whether an http:PushPromise exists for a previously-submitted request.

getNextPromise

Retrieves the next available http:PushPromise for a previously-submitted request.

getPromisedResponse

Retrieves the promised server push http:Response message.

rejectPromise

Rejects an http:PushPromise.

Methods

getSucceededEndpointIndex

Gets the index of the TargetService[] array which given a successful response.

post

function post(string path, RequestMessage message, map<string | string[ ]>? headers, string? mediaType, TargetType targetType) returns targetType | ClientError
Isolated Function
Remote Function

The POST remote function implementation of the Failover Connector.

Parameters

  • message RequestMessage
  • An HTTP outbound request or any allowed payload

  • mediaType string? (default ())
  • The MIME type header of the request entity

  • targetType TargetType (default <>)
  • HTTP response or the payload type (string, xml, json, byte[],record {| anydata...; |}, or record {| anydata...; |}[]), which is expected to be returned after data binding

Return Type

(targetType | ClientError)

The response or the payload (if the targetType is configured) or an http:ClientError if failed to establish the communication with the upstream server or a data binding failure

put

function put(string path, RequestMessage message, map<string | string[ ]>? headers, string? mediaType, TargetType targetType) returns targetType | ClientError
Isolated Function
Remote Function

The PUT remote function implementation of the Failover Connector.

Parameters

  • message RequestMessage
  • An HTTP outbound request or any allowed payload

  • mediaType string? (default ())
  • The MIME type header of the request entity

  • targetType TargetType (default <>)
  • HTTP response or the payload type (string, xml, json, byte[],record {| anydata...; |}, or record {| anydata...; |}[]), which is expected to be returned after data binding

Return Type

(targetType | ClientError)

The response or the payload (if the targetType is configured) or an http:ClientError if failed to establish the communication with the upstream server or a data binding failure

patch

function patch(string path, RequestMessage message, map<string | string[ ]>? headers, string? mediaType, TargetType targetType) returns targetType | ClientError
Isolated Function
Remote Function

The PATCH remote function implementation of the Failover Connector.

Parameters

  • message RequestMessage
  • An HTTP outbound request or any allowed payload

  • mediaType string? (default ())
  • The MIME type header of the request entity

  • targetType TargetType (default <>)
  • HTTP response or the payload type (string, xml, json, byte[],record {| anydata...; |}, or record {| anydata...; |}[]), which is expected to be returned after data binding

Return Type

(targetType | ClientError)

The response or the payload (if the targetType is configured) or an http:ClientError if failed to establish the communication with the upstream server or a data binding failure

delete

function delete(string path, RequestMessage message, map<string | string[ ]>? headers, string? mediaType, TargetType targetType) returns targetType | ClientError
Isolated Function
Remote Function

The DELETE remote function implementation of the Failover Connector.

Parameters

  • message RequestMessage (default ())
  • An optional HTTP outbound request message or any allowed payload

  • mediaType string? (default ())
  • The MIME type header of the request entity

  • targetType TargetType (default <>)
  • HTTP response or the payload type (string, xml, json, byte[],record {| anydata...; |}, or record {| anydata...; |}[]), which is expected to be returned after data binding

Return Type

(targetType | ClientError)

The response or the payload (if the targetType is configured) or an http:ClientError if failed to establish the communication with the upstream server or a data binding failure

function head(string path, map<string | string[ ]>? headers) returns Response | ClientError
Isolated Function
Remote Function

The HEAD remote function implementation of the Failover Connector.

Parameters

Return Type

(Response | ClientError)

The response or an http:ClientError if failed to establish the communication with the upstream server

get

function get(string path, map<string | string[ ]>? headers, TargetType targetType) returns targetType | ClientError
Isolated Function
Remote Function

The GET remote function implementation of the Failover Connector.

Parameters

  • targetType TargetType (default <>)
  • HTTP response or the payload type (string, xml, json, byte[],record {| anydata...; |}, or record {| anydata...; |}[]), which is expected to be returned after data binding

Return Type

(targetType | ClientError)

The response or the payload (if the targetType is configured) or an http:ClientError if failed to establish the communication with the upstream server or a data binding failure

options

function options(string path, map<string | string[ ]>? headers, TargetType targetType) returns targetType | ClientError
Isolated Function
Remote Function

The OPTIONS remote function implementation of the Failover Connector.

Parameters

  • targetType TargetType (default <>)
  • HTTP response or the payload type (string, xml, json, byte[],record {| anydata...; |}, or record {| anydata...; |}[]), which is expected to be returned after data binding

Return Type

(targetType | ClientError)

The response or the payload (if the targetType is configured) or an http:ClientError if failed to establish the communication with the upstream server or a data binding failure

execute

function execute(string httpVerb, string path, RequestMessage message, map<string | string[ ]>? headers, string? mediaType, TargetType targetType) returns targetType | ClientError
Isolated Function
Remote Function

Invokes an HTTP call with the specified HTTP method.

Parameters

  • httpVerb string
  • HTTP verb value

  • message RequestMessage
  • An HTTP outbound request or any allowed payload

  • mediaType string? (default ())
  • The MIME type header of the request entity

  • targetType TargetType (default <>)
  • HTTP response or the payload type (string, xml, json, byte[],record {| anydata...; |}, or record {| anydata...; |}[]), which is expected to be returned after data binding

Return Type

(targetType | ClientError)

The response or the payload (if the targetType is configured) or an http:ClientError if failed to establish the communication with the upstream server or a data binding failure

forward

function forward(string path, Request request, TargetType targetType) returns targetType | ClientError
Isolated Function
Remote Function

Invokes an HTTP call using the incoming request's HTTP method.

Parameters

  • targetType TargetType (default <>)
  • HTTP response or the payload type (string, xml, json, byte[],record {| anydata...; |}, or record {| anydata...; |}[]), which is expected to be returned after data binding

Return Type

(targetType | ClientError)

The response or the payload (if the targetType is configured) or an http:ClientError if failed to establish the communication with the upstream server or a data binding failure

submit

function submit(string httpVerb, string path, RequestMessage message) returns HttpFuture | ClientError
Isolated Function
Remote Function

Submits an HTTP request to a service with the specified HTTP verb. The FailoverClient.submit() function does not return an http:Response as the result. Rather it returns an http:HttpFuture which can be used for subsequent interactions with the HTTP endpoint.

Parameters

  • httpVerb string
  • The HTTP verb value

  • message RequestMessage
  • An HTTP outbound request or any allowed payload

Return Type

(HttpFuture | ClientError)

An http:HttpFuture that represents an asynchronous service invocation or else an http:ClientError if the submission fails

getResponse

function getResponse(HttpFuture httpFuture) returns Response | ClientError
Isolated Function
Remote Function

Retrieves the http:Response for a previously-submitted request.

Parameters

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

Return Type

(Response | ClientError)

An http:Response message or else an http:ClientError if the invocation fails

hasPromise

function hasPromise(HttpFuture httpFuture) returns boolean
Isolated Function
Remote Function

Checks whether an http:PushPromise exists for a previously-submitted request.

Parameters

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

Return Type

(boolean)

A boolean, which represents whether an http:PushPromise exists

getNextPromise

function getNextPromise(HttpFuture httpFuture) returns PushPromise | ClientError
Isolated Function
Remote Function

Retrieves the next available http:PushPromise for a previously-submitted request.

Parameters

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

Return Type

(PushPromise | ClientError)

An http:PushPromise message or else an http:ClientError if the invocation fails

getPromisedResponse

function getPromisedResponse(PushPromise promise) returns Response | ClientError
Isolated Function
Remote Function

Retrieves the promised server push http:Response message.

Parameters

Return Type

(Response | ClientError)

A promised http:Response message or else an http:ClientError if the invocation fails

rejectPromise

function rejectPromise(PushPromise promise)
Isolated Function
Remote Function

Rejects an http:PushPromise. When an http:PushPromise is rejected, there is no chance of fetching a promised response using the rejected promise.

Parameters

getSucceededEndpointIndex

function getSucceededEndpointIndex() returns int
Isolated Function

Gets the index of the TargetService[] array which given a successful response.

Return Type

(int)

The successful target endpoint index