]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/cpp/src/arrow/flight/client_middleware.h
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / cpp / src / arrow / flight / client_middleware.h
CommitLineData
1d09f67e
TL
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18// Interfaces for defining middleware for Flight clients. Currently
19// experimental.
20
21#pragma once
22
23#include <memory>
24
25#include "arrow/flight/middleware.h"
26#include "arrow/flight/visibility.h" // IWYU pragma: keep
27#include "arrow/status.h"
28
29namespace arrow {
30namespace flight {
31
32/// \brief Client-side middleware for a call, instantiated per RPC.
33///
34/// Middleware should be fast and must be infallible: there is no way
35/// to reject the call or report errors from the middleware instance.
36class ARROW_FLIGHT_EXPORT ClientMiddleware {
37 public:
38 virtual ~ClientMiddleware() = default;
39
40 /// \brief A callback before headers are sent. Extra headers can be
41 /// added, but existing ones cannot be read.
42 virtual void SendingHeaders(AddCallHeaders* outgoing_headers) = 0;
43
44 /// \brief A callback when headers are received from the server.
45 virtual void ReceivedHeaders(const CallHeaders& incoming_headers) = 0;
46
47 /// \brief A callback after the call has completed.
48 virtual void CallCompleted(const Status& status) = 0;
49};
50
51/// \brief A factory for new middleware instances.
52///
53/// If added to a client, this will be called for each RPC (including
54/// Handshake) to give the opportunity to intercept the call.
55///
56/// It is guaranteed that all client middleware methods are called
57/// from the same thread that calls the RPC method implementation.
58class ARROW_FLIGHT_EXPORT ClientMiddlewareFactory {
59 public:
60 virtual ~ClientMiddlewareFactory() = default;
61
62 /// \brief A callback for the start of a new call.
63 ///
64 /// \param info Information about the call.
65 /// \param[out] middleware The middleware instance for this call. If
66 /// unset, will not add middleware to this call instance from
67 /// this factory.
68 virtual void StartCall(const CallInfo& info,
69 std::unique_ptr<ClientMiddleware>* middleware) = 0;
70};
71
72} // namespace flight
73} // namespace arrow