• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TRANSPORT_TRANSPORT_FRAMING_ENDPOINT_EXTENSION_H
16 #define GRPC_SRC_CORE_LIB_TRANSPORT_TRANSPORT_FRAMING_ENDPOINT_EXTENSION_H
17 
18 #include <grpc/support/port_platform.h>
19 
20 #include "absl/functional/any_invocable.h"
21 #include "absl/strings/string_view.h"
22 #include "src/core/lib/slice/slice_buffer.h"
23 
24 namespace grpc_core {
25 
26 /// An Endpoint extension class that will be supported by EventEngine endpoints
27 /// which can send data to a transport and receive data from it.
28 class TransportFramingEndpointExtension {
29  public:
30   virtual ~TransportFramingEndpointExtension() = default;
EndpointExtensionName()31   static absl::string_view EndpointExtensionName() {
32     return "io.grpc.transport.extension.transport_framing_endpoint_"
33            "extension";
34   }
35 
36   // Send data to transport through `cb`. The data will be sent in a single
37   // frame.
38   virtual void SetSendFrameCallback(
39       absl::AnyInvocable<void(SliceBuffer* data)> cb) = 0;
40 
41   /// Receive data from transport. The data will be from a single frame.
42   virtual void ReceiveFrame(SliceBuffer data) = 0;
43 };
44 
45 }  // namespace grpc_core
46 
47 #endif  // GRPC_SRC_CORE_LIB_TRANSPORT_TRANSPORT_FRAMING_ENDPOINT_EXTENSION_H
48