proxygen
RoutingDataHandler.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017-present Facebook, Inc.
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 #pragma once
17 
19 
20 namespace wangle {
21 
22 template <typename R>
24  public:
25  struct RoutingData {
26  RoutingData() : bufQueue(folly::IOBufQueue::cacheChainLength()) {}
27 
30  };
31 
32  class Callback {
33  public:
34  virtual ~Callback() {}
35  virtual void onRoutingData(uint64_t connId, RoutingData& routingData) = 0;
36  virtual void onError(uint64_t connId, folly::exception_wrapper ex) = 0;
37  };
38 
39  RoutingDataHandler(uint64_t connId, Callback* cob);
40  ~RoutingDataHandler() override {}
41 
42  // BytesToBytesHandler implementation
43  void read(Context* ctx, folly::IOBufQueue& q) override;
44  void readEOF(Context* ctx) override;
45  void readException(Context* ctx, folly::exception_wrapper ex) override;
46 
60 
61  private:
63  Callback* cob_{nullptr};
64 };
65 
66 template <typename R>
68  public:
70 
71  virtual std::shared_ptr<RoutingDataHandler<R>> newHandler(
72  uint64_t connId, typename RoutingDataHandler<R>::Callback* cob) = 0;
73 };
74 
75 } // namespace wangle
76 
void read(Context *ctx, folly::IOBufQueue &q) override
RoutingDataHandler(uint64_t connId, Callback *cob)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
virtual bool parseRoutingData(folly::IOBufQueue &bufQueue, RoutingData &routingData)=0
void readException(Context *ctx, folly::exception_wrapper ex) override
void readEOF(Context *ctx) override
Handler< R, R, W, W >::Context Context
Definition: Handler.h:161