0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

ircd::client: Use conf::item's for client related.

This commit is contained in:
Jason Volk 2018-04-19 16:35:59 -07:00
parent d2536c83a2
commit 7d64e6323b
2 changed files with 62 additions and 21 deletions

View file

@ -31,11 +31,6 @@ struct ircd::client
struct settings;
struct request;
static constexpr const size_t &HEAD_MAX
{
4_KiB
};
static struct settings settings;
static struct conf default_conf;
static ctx::pool context;
@ -83,31 +78,29 @@ struct ircd::client
/// Confs can be attached to individual clients to change their behavior
struct ircd::client::conf
{
static ircd::conf::item<seconds> async_timeout_default;
static ircd::conf::item<seconds> request_timeout_default;
static ircd::conf::item<size_t> header_max_size_default;
/// Default time limit for how long a client connection can be in "async mode"
/// (or idle mode) after which it is disconnected.
seconds async_timeout {35s};
seconds async_timeout {async_timeout_default};
/// Time limit for how long a connected client can be sending its request.
/// This is meaningful before the resource being sought is known (while
/// receiving headers), after which its own specific timeout specified by
/// its options takes over.
seconds request_timeout {15s};
seconds request_timeout {request_timeout_default};
/// Number of bytes allocated to receive HTTP request headers for client.
size_t header_max_size {header_max_size_default};
};
/// Settings apply to all clients and cannot be configured per-client
struct ircd::client::settings
{
/// TODO
size_t stack_size
{
1_MiB
};
/// TODO
size_t pool_size
{
128
};
static ircd::conf::item<size_t> stack_size;
static ircd::conf::item<size_t> pool_size;
};
struct ircd::client::init

View file

@ -17,23 +17,70 @@ namespace ircd
template<class... args> std::shared_ptr<client> make_client(args&&...);
}
//
// client::settings conf::item's
//
ircd::conf::item<size_t>
ircd::client::settings::stack_size
{
{ "name", "ircd.client.stack_size" },
{ "default", ssize_t(1_MiB) },
};
ircd::conf::item<size_t>
ircd::client::settings::pool_size
{
{ "name", "ircd.client.pool_size " },
{ "default", 64L },
};
/// Linkage for the default settings
decltype(ircd::client::settings)
ircd::client::settings
{};
//
// client::conf conf::item's
//
ircd::conf::item<ircd::seconds>
ircd::client::conf::async_timeout_default
{
{ "name", "ircd.client.conf.async_timeout" },
{ "default", 35L },
};
ircd::conf::item<ircd::seconds>
ircd::client::conf::request_timeout_default
{
{ "name", "ircd.client.conf.request_timeout" },
{ "default", 15L },
};
ircd::conf::item<size_t>
ircd::client::conf::header_max_size_default
{
{ "name", "ircd.client.conf.header_max_size" },
{ "default", ssize_t(8_KiB) },
};
/// Linkage for the default conf
decltype(ircd::client::default_conf)
ircd::client::default_conf
{};
//
// linkages
//
/// The pool of request contexts. When a client makes a request it does so by acquiring
/// a stack from this pool. The request handling and response logic can then be written
/// in a synchronous manner as if each connection had its own thread.
ircd::ctx::pool
ircd::client::context
{
"client", settings.stack_size
"client", size_t(settings.stack_size)
};
decltype(ircd::client::ctr)
@ -52,7 +99,7 @@ ircd::util::instance_list<ircd::client>::list
ircd::client::init::init()
{
context.add(settings.pool_size);
context.add(size_t(settings.pool_size));
}
ircd::client::init::~init()
@ -512,9 +559,10 @@ ircd::client::client()
}
ircd::client::client(std::shared_ptr<socket> sock)
:head_buffer{HEAD_MAX}
:head_buffer{conf->header_max_size}
,sock{std::move(sock)}
{
assert(size(head_buffer) >= 8_KiB);
}
ircd::client::~client()