xref: /aosp_15_r20/external/federated-compute/fcp/client/secagg_event_publisher.h (revision 14675a029014e728ec732f129a32e299b2da0601)
1 /*
2  * Copyright 2020 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef FCP_CLIENT_SECAGG_EVENT_PUBLISHER_H_
17 #define FCP_CLIENT_SECAGG_EVENT_PUBLISHER_H_
18 
19 #include <cstdint>
20 #include <string>
21 
22 namespace fcp::secagg {
23 enum class ClientState : int;
24 }  // namespace fcp::secagg
25 
26 namespace fcp {
27 namespace client {
28 
29 // An interface for publishing events that occur during the secure
30 // aggregation protocol. All methods in here either succeed with OK, or fail
31 // with INVALID_ARGUMENT.
32 class SecAggEventPublisher {
33  public:
34   virtual ~SecAggEventPublisher() = default;
35 
36   // Publishes that the protocol has left the prior state and entered the
37   // given state, along with the size of the last message sent.
38   virtual void PublishStateTransition(::fcp::secagg::ClientState state,
39                                       size_t last_sent_message_size,
40                                       size_t last_received_message_size) = 0;
41   // Publishes a top-level SecAgg client error.
42   virtual void PublishError() = 0;
43   // Publishes a SecAgg client abort.
44   virtual void PublishAbort(bool client_initiated,
45                             const std::string& error_message) = 0;
46   // After calling this function, all subsequently published events will be
47   // annotated with the specified execution logging ID, which is set during
48   // protocol execution.
49   virtual void set_execution_session_id(int64_t execution_session_id) = 0;
50 };
51 
52 }  // namespace client
53 }  // namespace fcp
54 
55 #endif  // FCP_CLIENT_SECAGG_EVENT_PUBLISHER_H_
56