blob: 0cb11af350e40b6f7d821a165b05ea2e8cf9d036 [file] [log] [blame]
Jens Geyera019cda2019-11-09 23:24:52 +01001(*
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
20unit Thrift.Configuration;
21
22interface
23
24uses
25 SysUtils, Generics.Collections, Generics.Defaults;
26
27const
28 DEFAULT_RECURSION_LIMIT = 64;
29 DEFAULT_MAX_MESSAGE_SIZE = 100 * 1024 * 1024; // 100 MB
30 DEFAULT_MAX_FRAME_SIZE = 16384000; // this value is used consistently across all Thrift libraries
31
32 DEFAULT_THRIFT_TIMEOUT = 5 * 1000; // ms
33
34type
35 IThriftConfiguration = interface
36 ['{ADD75449-1A67-4B78-9B75-502A1E338CFC}']
37 function GetRecursionLimit : Cardinal;
38 procedure SetRecursionLimit( const value : Cardinal);
39 function GetMaxFrameSize : Cardinal;
40 procedure SetMaxFrameSize( const value : Cardinal);
41 function GetMaxMessageSize : Cardinal;
42 procedure SetMaxMessageSize( const value : Cardinal);
43
44 property RecursionLimit : Cardinal read GetRecursionLimit write SetRecursionLimit;
45 property MaxFrameSize : Cardinal read GetMaxFrameSize write SetMaxFrameSize;
46 property MaxMessageSize : Cardinal read GetMaxMessageSize write SetMaxMessageSize;
47 end;
48
49
50 TThriftConfigurationImpl = class( TInterfacedObject, IThriftConfiguration)
51 strict protected
52 FRecursionLimit : Cardinal;
53 FMaxFrameSize : Cardinal;
54 FMaxMessageSize : Cardinal;
55
56 // IThriftConfiguration
57 function GetRecursionLimit : Cardinal;
58 procedure SetRecursionLimit( const value : Cardinal);
59 function GetMaxFrameSize : Cardinal;
60 procedure SetMaxFrameSize( const value : Cardinal);
61 function GetMaxMessageSize : Cardinal;
62 procedure SetMaxMessageSize( const value : Cardinal);
63
64 public
65 constructor Create;
66 end;
67
68
69implementation
70
71
72{ TThriftConfigurationImpl }
73
74
75constructor TThriftConfigurationImpl.Create;
76begin
77 inherited Create;
78
79 FRecursionLimit := DEFAULT_RECURSION_LIMIT;
80 FMaxFrameSize := DEFAULT_MAX_FRAME_SIZE;
81 FMaxMessageSize := DEFAULT_MAX_MESSAGE_SIZE;
82end;
83
84
85function TThriftConfigurationImpl.GetRecursionLimit: Cardinal;
86begin
87 result := FRecursionLimit;
88end;
89
90
91procedure TThriftConfigurationImpl.SetRecursionLimit(const value: Cardinal);
92begin
93 FRecursionLimit := value;
94end;
95
96
97function TThriftConfigurationImpl.GetMaxFrameSize: Cardinal;
98begin
99 result := FMaxFrameSize;
100end;
101
102
103procedure TThriftConfigurationImpl.SetMaxFrameSize(const value: Cardinal);
104begin
105 FMaxFrameSize := value;
106end;
107
108
109function TThriftConfigurationImpl.GetMaxMessageSize: Cardinal;
110begin
111 result := FMaxMessageSize;
112end;
113
114
115procedure TThriftConfigurationImpl.SetMaxMessageSize(const value: Cardinal);
116begin
117 FMaxMessageSize := value;
118end;
119
120
121end.