Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions include/up-cpp/client/usubscription/v3/USubscriptionUUriBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,40 @@ struct USubscriptionUUriBuilder {
/// @brief Constructor for uSubscriptionUUriBuilder.
USubscriptionUUriBuilder();

/// @brief Sets the authority name that will be used to build URIs.
///
/// @param authority_name The authority to set in the URI.
///
/// @return Returns a reference to the builder instance
USubscriptionUUriBuilder& setAuthorityName(
const std::string& authority_name);

/// @brief Sets the uEntity id that will be used to build URIs.
///
/// @param ue_id The uEntity id to set in the URI.
///
/// @return Returns a reference to the builder instance
USubscriptionUUriBuilder& setUEntityId(uint32_t ue_id);

///
/// @brief Sets the instance id that will be used to build URIs.
/// @param instance_id The instance id to set in the URI.
///
/// @return Returns a reference to the builder instance
USubscriptionUUriBuilder& setInstanceId(uint16_t instance_id);

/// @brief Sets the service id that will be used to build URIs.
/// @param service_id The service id to set in the URI.
///
/// @return Returns a reference to the builder instance
USubscriptionUUriBuilder& setServiceId(uint16_t service_id);

/// @brief Sets the resource id that will be used to build URIs.
/// @param resource_id The resource id to set in the URI.
///
/// @return Returns a reference to the builder instance
USubscriptionUUriBuilder& setResourceId(uint32_t resource_id);

/// @brief Get the URI with a specific resource ID.
///
/// @param resource_id The resource ID to set in the URI.
Expand Down
60 changes: 51 additions & 9 deletions include/up-cpp/communication/RpcClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,24 @@ struct RpcClient {
/// * A UMessage containing the response from the RPC target.
[[nodiscard]] InvokeFuture invokeMethod(const v1::UUri&);

/// @brief Invokes an RPC method by sending a request message directly
/// from a protobuf object.
///
/// @param The method that will be invoked
/// @param The protobuf object that will be sent as the payload
/// @param A callback that will be called with the result.
///
/// @post The provided callback will be called with one of:
/// * A UStatus with a DEADLINE_EXCEEDED code if no response was
/// received before the request expired (based on request TTL).
/// * A UStatus with the value returned by UTransport::send().
/// * A UStatus based on the commstatus received in the response
/// message (if not OK).
/// * A UMessage containing the response from the RPC target.
template <typename R>
InvokeHandle invokeMethodToProto(const v1::UUri& method,
const R& request_message,
Callback&& callback) {
[[nodiscard]] InvokeHandle invokeMethodFromProto(const v1::UUri& method,
const R& request_message,
Callback&& callback) {
auto payload_or_status =
uprotocol::utils::ProtoConverter::protoToPayload(request_message);

Expand All @@ -199,13 +213,29 @@ struct RpcClient {
return handle;
}

/// @brief Invokes an RPC method by sending a request message directly
/// from a protobuf object and converts the returned payload
/// to protobuf.
///
/// @param The method that will be invoked
/// @param The protobuf object that will be sent as the payload
/// @param A callback that will be called with the result.
///
/// @returns A promised future that can resolve to one of:
/// * A UStatus with a DEADLINE_EXCEEDED code if no response was
/// received before the request expired (based on request TTL).
/// * A UStatus with the value returned by UTransport::send().
/// * A UStatus based on the commstatus received in the response
/// message (if not OK).
/// * A protobuf object constructed from the response from the RPC
/// target.
template <typename T, typename R>
InvokeProtoFuture<T> invokeMethodToProto(const v1::UUri& method,
const R& request_message) {
[[nodiscard]] InvokeProtoFuture<T> invokeMethodToProto(
const v1::UUri& method, const R& request_message) {
auto result_promise =
std::make_shared<std::promise<ResponseOrStatus<T>>>();
auto future = result_promise->get_future();
auto handle = invokeMethodToProto(
auto handle = invokeMethodFromProto(
method, request_message,
[result_promise](const MessageOrStatus& message_or_status) {
if (!message_or_status.has_value()) {
Expand Down Expand Up @@ -233,14 +263,26 @@ struct RpcClient {
return {std::move(future), std::move(handle)};
}

/// @brief Invokes an RPC method by sending a request message.
///
/// @param The method that will be invoked
/// @param The protobuf object that will be sent as a payload.
///
/// @returns A promised future that can resolve to one of:
/// * A UStatus with a DEADLINE_EXCEEDED code if no response was
/// received before the request expired (based on request TTL).
/// * A UStatus with the value returned by UTransport::send().
/// * A UStatus based on the commstatus received in the response
/// message (if not OK).
/// * A UMessage containing the response from the RPC target.
template <typename R>
InvokeFuture invokeMethodToProto(const v1::UUri& method,
const R& request_message) {
[[nodiscard]] InvokeFuture invokeMethodFromProto(const v1::UUri& method,
const R& request_message) {
auto result_promise =
std::make_shared<std::promise<ResponseOrStatus<v1::UMessage>>>();
auto future = result_promise->get_future();

auto handle = invokeMethodToProto(
auto handle = invokeMethodFromProto(
method, request_message,
[result_promise](const MessageOrStatus& message_or_status) {
if (!message_or_status.has_value()) {
Expand Down
55 changes: 0 additions & 55 deletions include/up-cpp/utils/ThreadPool.h

This file was deleted.

49 changes: 0 additions & 49 deletions include/up-cpp/utils/base64.h

This file was deleted.

12 changes: 0 additions & 12 deletions src/utils/ThreadPool.cpp

This file was deleted.

12 changes: 0 additions & 12 deletions src/utils/base64.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ endfunction()
########################### COVERAGE ##########################################
# Utils
add_coverage_test("ExpectedTest" coverage/utils/ExpectedTest.cpp)
add_coverage_test("base64Test" coverage/utils/base64Test.cpp)
add_coverage_test("IpAddressTest" coverage/utils/IpAddressTest.cpp)
add_coverage_test("CallbackConnectionTest" coverage/utils/CallbackConnectionTest.cpp)
add_coverage_test("CyclicQueueTest" coverage/utils/CyclicQueueTest.cpp)
add_coverage_test("ThreadPoolTest" coverage/utils/ThreadPoolTest.cpp)

# Validators
add_coverage_test("UuidValidatorTest" coverage/datamodel/UuidValidatorTest.cpp)
Expand Down
40 changes: 0 additions & 40 deletions test/coverage/utils/ThreadPoolTest.cpp

This file was deleted.

40 changes: 0 additions & 40 deletions test/coverage/utils/base64Test.cpp

This file was deleted.