xref: /aosp_15_r20/external/grpc-grpc/src/core/lib/event_engine/extensions/chaotic_good_extension.h (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1 // Copyright 2024 The gRPC Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GRPC_SRC_CORE_LIB_EVENT_ENGINE_EXTENSIONS_CHAOTIC_GOOD_EXTENSION_H
16 #define GRPC_SRC_CORE_LIB_EVENT_ENGINE_EXTENSIONS_CHAOTIC_GOOD_EXTENSION_H
17 
18 #include <grpc/support/port_platform.h>
19 
20 #include "absl/strings/string_view.h"
21 
22 #include "src/core/lib/resource_quota/memory_quota.h"
23 
24 namespace grpc_event_engine {
25 namespace experimental {
26 
27 /// An Endpoint extension class that will be supported by EventEngine endpoints
28 /// which need to work with the ChaoticGood transport.
29 class ChaoticGoodExtension {
30  public:
31   virtual ~ChaoticGoodExtension() = default;
EndpointExtensionName()32   static absl::string_view EndpointExtensionName() {
33     return "io.grpc.event_engine.extension.chaotic_good_extension";
34   }
35 
36   /// If invoked, the endpoint begins collecting TCP stats. If the boolean
37   /// arg is_control_channel is true, then the collected stats are grouped into
38   /// histograms and counters specific to the chaotic good control channel.
39   /// Otherwise they are grouped into histograms and counters specific to the
40   /// chaotic good data channel.
41   virtual void EnableStatsCollection(bool is_control_channel) = 0;
42 
43   /// Forces the endpoint to use the provided memory quota instead of using the
44   /// one provided to it through the channel args. It is safe to call this
45   /// only when there are no outstanding Reads on the Endpoint.
46   virtual void UseMemoryQuota(grpc_core::MemoryQuotaRefPtr mem_quota) = 0;
47 
48   /// Forces the endpoint to receive rpcs in one contiguous block of memory.
49   /// It is safe to call this only when there are no outstanding Reads on
50   /// the Endpoint.
51   virtual void EnableRpcReceiveCoalescing() = 0;
52 
53   /// Disables rpc receive coalescing until it is explicitly enabled again.
54   /// It is safe to call this only when there are no outstanding Reads on
55   /// the Endpoint.
56   virtual void DisableRpcReceiveCoalescing() = 0;
57   /// If invoked, the endpoint tries to preserve proper order and alignment of
58   /// any memory that maybe shared across reads.
59   virtual void EnforceRxMemoryAlignment() = 0;
60 };
61 
62 }  // namespace experimental
63 }  // namespace grpc_event_engine
64 
65 #endif  // GRPC_SRC_CORE_LIB_EVENT_ENGINE_EXTENSIONS_CHAOTIC_GOOD_EXTENSION_H
66