Class ServiceClient

Inheritance Relationships

Base Type

Class Documentation

class ServiceClient : public email::ServiceObject

Service client.

Sends a request to a service server and gets a response.

Public Functions

explicit ServiceClient(const std::string &service_name)

Constructor.

Parameters:

service_name – the service name

~ServiceClient()
void send_request(const std::string &request, const SequenceNumber sequence_number)

Send request with specific ID.

For asynchronous sending of a request. TODO(christophebedard) remove this one since we don’t need it

Parameters:
  • request – the request

  • sequence_number – the sequence number; to use for getting the corresponding response

SequenceNumber send_request(const std::string &request)

Send request.

For asynchronous sending of a request.

Parameters:

request – the request

Returns:

the sequence_number to use for getting the corresponding response

bool has_response(const SequenceNumber sequence_number)

Check if the client has an available response to a request.

Parameters:

sequence_number – the request sequence number

Returns:

true if there is an available response, false otherwise

bool has_response()

Check if the client has an available response to any request.

Note: has_response(SequenceNumber) should be used instead.

Returns:

true if there is an available response, false otherwise

std::optional<std::string> get_response(const SequenceNumber sequence_number)

Get a response if there is one.

Parameters:

sequence_number – the request sequence number

Returns:

the response, or std::nullopt if there is none

std::optional<std::pair<std::string, ServiceInfo>> get_response_with_info(const SequenceNumber sequence_number)

Get a response with info if there is one.

Parameters:

sequence_number – the request sequence number

Returns:

the response with info, or std::nullopt if there is none

std::optional<std::pair<std::string, ServiceInfo>> get_response_with_info()

Get a response with info if there is one.

This returns the first response in the internal map.

Returns:

the response with info, or std::nullopt if there is none