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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
21 * Various helpers used by more than a single test.
25 import std
.parallelism
: TaskPool
;
26 import thrift
.protocol
.base
;
27 import thrift
.protocol
.processor
;
28 import thrift
.server
.base
;
29 import thrift
.server
.nonblocking
;
30 import thrift
.server
.simple
;
31 import thrift
.server
.taskpool
;
32 import thrift
.server
.threaded
;
33 import thrift
.server
.transport
.socket
;
34 import thrift
.transport
.base
;
35 import thrift
.transport
.buffered
;
36 import thrift
.transport
.framed
;
37 import thrift
.transport
.http
;
39 // This is a likely victim of @@BUG4744@@ when used with command argument
49 TServer
createServer(ServerType type
, size_t taskPoolSize
, size_t numIOThreads
,
50 TProcessor processor
, TServerSocket serverTransport
,
51 TTransportFactory transportFactory
, TProtocolFactory protocolFactory
)
54 case ServerType
.simple
:
55 return new TSimpleServer(processor
, serverTransport
,
56 transportFactory
, protocolFactory
);
57 case ServerType
.nonblocking
:
58 auto nb
= new TNonblockingServer(processor
, serverTransport
.port
,
59 transportFactory
, protocolFactory
);
60 nb
.numIOThreads
= numIOThreads
;
62 case ServerType
.pooledNonblocking
:
63 auto nb
= new TNonblockingServer(processor
, serverTransport
.port
,
64 transportFactory
, protocolFactory
, new TaskPool(taskPoolSize
));
65 nb
.numIOThreads
= numIOThreads
;
67 case ServerType
.taskpool
:
68 auto tps
= new TTaskPoolServer(processor
, serverTransport
,
69 transportFactory
, protocolFactory
);
70 tps
.taskPool
= new TaskPool(taskPoolSize
);
72 case ServerType
.threaded
:
73 return new TThreadedServer(processor
, serverTransport
,
74 transportFactory
, protocolFactory
);
85 TTransportFactory
createTransportFactory(TransportType type
) {
87 case TransportType
.buffered
:
88 return new TBufferedTransportFactory
;
89 case TransportType
.framed
:
90 return new TFramedTransportFactory
;
91 case TransportType
.http
:
92 return new TServerHttpTransportFactory
;
93 case TransportType
.raw
:
94 return new TTransportFactory
;