zeshuai007 | 86352b4 | 2020-06-15 17:00:33 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | #ifndef THRIFT_TCONFIGURATION_H |
| 21 | #define THRIFT_TCONFIGURATION_H |
| 22 | |
| 23 | namespace apache { |
| 24 | namespace thrift { |
| 25 | |
| 26 | class TConfiguration |
| 27 | { |
| 28 | public: |
| 29 | TConfiguration(int maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE, |
| 30 | int maxFrameSize = DEFAULT_MAX_FRAME_SIZE, int recursionLimit = DEFAULT_RECURSION_DEPTH) |
| 31 | : maxMessageSize_(maxMessageSize), maxFrameSize_(maxFrameSize), recursionLimit_(recursionLimit) {} |
| 32 | |
| 33 | const static int DEFAULT_MAX_MESSAGE_SIZE = 100 * 1024 * 1024; |
| 34 | const static int DEFAULT_MAX_FRAME_SIZE = 16384000; // this value is used consistently across all Thrift libraries |
| 35 | const static int DEFAULT_RECURSION_DEPTH = 64; |
| 36 | |
| 37 | inline int getMaxMessageSize() { return maxMessageSize_; } |
| 38 | inline void setMaxMessageSize(int maxMessageSize) { maxMessageSize_ = maxMessageSize; } |
| 39 | inline int getMaxFrameSize() { return maxFrameSize_; } |
| 40 | inline void setMaxFrameSize(int maxFrameSize) { maxFrameSize_ = maxFrameSize; } |
| 41 | inline int getRecursionLimit() { return recursionLimit_; } |
| 42 | inline void setRecursionLimit(int recursionLimit) { recursionLimit_ = recursionLimit; } |
| 43 | |
| 44 | private: |
| 45 | int maxMessageSize_ = DEFAULT_MAX_MESSAGE_SIZE; |
| 46 | int maxFrameSize_ = DEFAULT_MAX_FRAME_SIZE; |
| 47 | int recursionLimit_ = DEFAULT_RECURSION_DEPTH; |
| 48 | |
| 49 | // TODO(someone_smart): add connection and i/o timeouts |
| 50 | }; |
| 51 | } |
| 52 | } // apache::thrift |
| 53 | |
| 54 | #endif /* THRIFT_TCONFIGURATION_H */ |
| 55 | |