Skip to content

Commit

Permalink
interface: Remove const from BatchCallback
Browse files Browse the repository at this point in the history
This enables the clients to filter out the
responses with errors without making a copy
of the returned responses.

Bug: NA
Change-Id: I8bcdd2b2321c440d26415fc1baf9df5548ec9ded
GitOrigin-RevId: 948beb69435932e512258f83dcd2e37c83e1f829
  • Loading branch information
Privacy Sandbox Team authored and copybara-github committed Sep 25, 2024
1 parent 91f160c commit 99e1450
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/roma/interface/roma.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ struct ResponseObject {
using Callback = absl::AnyInvocable<void(absl::StatusOr<ResponseObject>)>;

// Batch API
// void Callback(const vector<ResponseObject>&);
using BatchCallback = absl::AnyInvocable<void(
const std::vector<absl::StatusOr<ResponseObject>>&)>;
// void Callback(vector<ResponseObject>);
using BatchCallback =
absl::AnyInvocable<void(std::vector<absl::StatusOr<ResponseObject>>)>;
} // namespace google::scp::roma

#endif // ROMA_INTERFACE_ROMA_H_
7 changes: 3 additions & 4 deletions src/roma/roma_service/roma_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,8 @@ class RomaService {
auto batch_callback_ptr = std::make_shared<BatchCallback>(
[&, uuids = std::move(uuids),
batch_callback = std::move(batch_callback)](
const std::vector<absl::StatusOr<ResponseObject>>&
batch_resp) mutable {
std::move(batch_callback)(batch_resp);
std::vector<absl::StatusOr<ResponseObject>> batch_resp) mutable {
std::move(batch_callback)(std::move(batch_resp));
for (const auto& uuid : uuids) {
DeleteMetadata(uuid);
}
Expand All @@ -402,7 +401,7 @@ class RomaService {
(*batch_response)[index] = std::move(obj_response);
auto finished_value = finished_counter->fetch_add(1);
if (finished_value + 1 == batch_response->size()) {
(*batch_callback_ptr)(*batch_response);
(*batch_callback_ptr)(std::move(*batch_response));
}
};
absl::Status result;
Expand Down

0 comments on commit 99e1450

Please sign in to comment.