Repository navigation
Expand file tree
/
Copy pathHTTPServerOptions.h
More file actions
86 lines (76 loc) · 2.32 KB
/
Copy pathHTTPServerOptions.h
File metadata and controls
86 lines (76 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include "proxygen/httpserver/Filters.h"
#include "proxygen/httpserver/RequestHandlerFactory.h"
#include <folly/SocketAddress.h>
#include <signal.h>
namespace proxygen {
/**
* Configuration options for HTTPServer
*
* XXX: Provide a helper that can convert thrift/json to this config
* directly. We keep this object type-safe.
*/
class HTTPServerOptions {
public:
/**
* Number of threads to start to handle requests. Note that this excludes
* the thread you call `HTTPServer.start()` in.
*
* XXX: Put some perf numbers to help user decide how many threads to
* create.
* XXX: Maybe support not creating any more worker threads and doing all
* the work in same thread when `threads == 0`.
*/
size_t threads = 1;
/**
* Chain of RequestHandlerFactory that are used to create RequestHandler
* which handles requests.
*
* You can do something like -
*
* handlerFactories = RequestHandlerChain()
* .addThen<StatsFilter>()
* .addThen<TraceFilter>()
* .addThen<AccessLogFilter>()
* .addThen<AppSpecificHandler>()
* .build();
*/
std::vector<std::unique_ptr<RequestHandlerFactory>> handlerFactories;
/**
* This idle timeout serves two purposes -
*
* 1. How long to keep idle connections around before throwing them away.
*
* 2. If it takes client more than this time to send request, we fail the
* request.
*
* XXX: Maybe have separate time limit for both?
*/
std::chrono::milliseconds idleTimeout{60000};
/**
* TCP server socket backlog to start with.
*/
uint32_t listenBacklog{1024};
/**
* Signals on which to shutdown the server. Mostly you will want
* {SIGINT, SIGTERM}. Note, if you have multiple deamons running or you want
* to have a separate signal handler, leave this empty and handle signals
* yourself.
*/
std::vector<int> shutdownOn{};
/**
* Set to true if you want to support CONNECT request. Most likely you
* don't want that.
*/
bool supportsConnect{false};
};
}