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

ircd::conf: Add reference to conf::item in setter callbacks.

This commit is contained in:
Jason Volk 2023-02-27 14:21:08 -08:00
parent e83bc5d930
commit 2c3dab1abc
27 changed files with 123 additions and 71 deletions

View file

@ -53,7 +53,7 @@ namespace ircd::conf
IRCD_EXCEPTION(error, not_found)
IRCD_EXCEPTION(error, bad_value)
using set_cb = std::function<void ()>;
using set_cb = std::function<void (item<void> &)>;
const size_t NAME_MAX_LEN {127};
const size_t VALUE_MAX_LEN {48_KiB};

View file

@ -39,7 +39,8 @@ ircd::client::settings::pool_size
{
{ "name", "ircd.client.pool_size" },
{ "default", 96L },
}, []
},
[](conf::item<void> &)
{
if(run::level == run::level::RUN)
client::pool.set(client::settings::pool_size);

View file

@ -63,7 +63,7 @@ try
if(!item.set_cb)
return false;
item.set_cb();
item.set_cb(item);
return true;
}
catch(const std::out_of_range &e)
@ -359,7 +359,7 @@ noexcept try
if(on_set(default_))
if(set_cb)
set_cb();
set_cb(*this);
}
catch(const std::exception &e)
{
@ -381,7 +381,7 @@ ircd::conf::item<void>::set(const string_view &val)
{
if(on_set(val))
if(set_cb)
set_cb();
set_cb(*this);
}
catch(...)
{
@ -389,7 +389,7 @@ ircd::conf::item<void>::set(const string_view &val)
{
if(on_set(existing))
if(set_cb)
set_cb();
set_cb(*this);
}
catch(...)
{

View file

@ -62,7 +62,8 @@ ircd::db::request_pool_size
{
{ "name", "ircd.db.request_pool.size" },
{ "default", 0L },
}, []
},
[](conf::item<void> &)
{
request.set(size_t(request_pool_size));
}

View file

@ -22,7 +22,7 @@ namespace ircd::fs
{
extern conf::item<ulong> rlimit_nofile;
static void update_rlimit_nofile();
static void update_rlimit_nofile(conf::item<void> &);
static void init_dump_info();
}
@ -74,7 +74,7 @@ ircd::fs::init_dump_info()
#if defined(HAVE_SYS_RESOURCE_H) && defined(RLIMIT_NOFILE)
void
ircd::fs::update_rlimit_nofile()
ircd::fs::update_rlimit_nofile(conf::item<void> &)
try
{
rlimit rlim[2];

View file

@ -35,7 +35,7 @@ namespace ircd::gpt::model
static bool init_from_cache(const string_view &);
static void init_from_json_handle(decoder &, const init_handler &, const size_t &);
static void init_from_json(const string_view &, const string_view &);
static void init(), fini() noexcept;
static void init(conf::item<void> &), fini() noexcept;
extern const init_handler
manifest[],
@ -157,7 +157,7 @@ decltype(ircd::gpt::model::default_data)
ircd::gpt::model::default_data;
void
ircd::gpt::model::init()
ircd::gpt::model::init(conf::item<void> &)
{
if(!model::path)
return;

View file

@ -22,7 +22,7 @@ namespace ircd::gpt::vocab
static u64x2 pre_tokenize(u8x16 (&)[16], const u8x16, const u8x16);
static u64x2 unk_tokenize(u16x16 &, const u8x16, u64);
static u64x2 tokenize_block(u16x16 &, const u8x16, const i8x16) noexcept;
static void init_tokens(), init_merges();
static void init_tokens(conf::item<void> &), init_merges(conf::item<void> &);
extern const char32_t charset[256];
}
@ -102,7 +102,7 @@ ircd::gpt::vocab::merges_path
};
void
ircd::gpt::vocab::init_tokens()
ircd::gpt::vocab::init_tokens(conf::item<void> &)
{
if(!tokens_path)
return;
@ -147,7 +147,7 @@ ircd::gpt::vocab::init_tokens()
}
void
ircd::gpt::vocab::init_merges()
ircd::gpt::vocab::init_merges(conf::item<void> &)
{
if(!merges_path)
return;

View file

@ -97,7 +97,8 @@ ircd::maintenance
{ "name", "ircd.maintenance" },
{ "default", false },
{ "persist", false },
}, []
},
[](conf::item<void> &)
{
if(!maintenance)
return;
@ -117,7 +118,8 @@ ircd::write_avoid
{ "name", "ircd.write_avoid" },
{ "default", false },
{ "persist", false },
}, []
},
[](conf::item<void> &)
{
if(!write_avoid)
return;
@ -137,7 +139,8 @@ ircd::read_only
{ "name", "ircd.read_only" },
{ "default", false },
{ "persist", false },
}, []
},
[](conf::item<void> &)
{
if(!read_only)
return;

View file

@ -854,7 +854,8 @@ ircd::log::unmask_file
{
{ "name", "ircd.log.unmask.file" },
{ "default", string_view{} },
}, []
},
[](conf::item<void> &)
{
if(!empty(string_view(unmask_file)))
file_unmask(tokens<std::vector>(unmask_file, ' '));
@ -868,7 +869,8 @@ ircd::log::unmask_console
{
{ "name", "ircd.log.unmask.console" },
{ "default", string_view{} },
}, []
},
[](conf::item<void> &)
{
if(!empty(string_view(unmask_console)))
console_unmask(tokens<std::vector>(unmask_console, ' '));
@ -882,7 +884,8 @@ ircd::log::mask_file
{
{ "name", "ircd.log.mask.file" },
{ "default", string_view{} },
}, []
},
[](conf::item<void> &)
{
if(!empty(string_view(mask_file)))
file_mask(tokens<std::vector>(mask_file, ' '));
@ -896,7 +899,8 @@ ircd::log::mask_console
{
{ "name", "ircd.log.mask.console" },
{ "default", string_view{} },
}, []
},
[](conf::item<void> &)
{
if(!empty(string_view(mask_console)))
console_mask(tokens<std::vector>(mask_console, ' '));

View file

@ -45,7 +45,8 @@ ircd::net::dns::resolver::servers
{
{ "name", "ircd.net.dns.resolver.servers" },
{ "default", "4.2.2.1 4.2.2.2 4.2.2.3 4.2.2.4 4.2.2.5 4.2.2.6" },
}, []
},
[](conf::item<void> &)
{
if(bool(ircd::net::dns::resolver_instance))
ircd::net::dns::resolver_instance->set_servers();

View file

@ -817,7 +817,7 @@ ircd::server::peer::only_ipv6
{ "name", "ircd.server.peer.ipv6.only" },
{ "default", net::sock_opts::IGN },
},
[]() noexcept
[](conf::item<void> &) noexcept
{
sock_opts.v6only = ssize_t(only_ipv6);
}
@ -830,7 +830,7 @@ ircd::server::peer::sock_nodelay
{ "name", "ircd.server.peer.sock.nodelay" },
{ "default", long(true) },
},
[]() noexcept
[](conf::item<void> &) noexcept
{
sock_opts.nodelay = ssize_t(sock_nodelay);
}
@ -843,7 +843,7 @@ ircd::server::peer::sock_read_bufsz
{ "name", "ircd.server.peer.sock.read.bufsz" },
{ "default", net::sock_opts::IGN },
},
[]() noexcept
[](conf::item<void> &) noexcept
{
sock_opts.read_bufsz = ssize_t(sock_read_bufsz);
}
@ -856,7 +856,7 @@ ircd::server::peer::sock_read_lowat
{ "name", "ircd.server.peer.sock.read.lowat" },
{ "default", net::sock_opts::IGN },
},
[]() noexcept
[](conf::item<void> &) noexcept
{
sock_opts.read_lowat = ssize_t(sock_read_lowat);
}
@ -869,7 +869,7 @@ ircd::server::peer::sock_write_bufsz
{ "name", "ircd.server.peer.sock.write.bufsz" },
{ "default", net::sock_opts::IGN },
},
[]() noexcept
[](conf::item<void> &) noexcept
{
sock_opts.write_bufsz = ssize_t(sock_write_bufsz);
}
@ -882,7 +882,7 @@ ircd::server::peer::sock_write_lowat
{ "name", "ircd.server.peer.sock.write.lowat" },
{ "default", net::sock_opts::IGN },
},
[]() noexcept
[](conf::item<void> &) noexcept
{
sock_opts.write_lowat = ssize_t(sock_write_lowat);
}

View file

@ -64,7 +64,8 @@ ircd::m::dbs::sst_write_buffer_size
{
{ "name", "ircd.m.dbs.sst.write_buffer_size" },
{ "default", long(1_MiB) },
}, []
},
[](conf::item<void> &)
{
static const string_view key{"writable_file_max_buffer_size"};
const size_t &value{sst_write_buffer_size};

View file

@ -60,7 +60,8 @@ ircd::m::dbs::desc::event_id__cache__size
{
{ "name", "ircd.m.dbs.event_id.cache.size" },
{ "default", long(48_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "event_id"_>()));
const size_t &value{event_id__cache__size};
@ -74,7 +75,8 @@ ircd::m::dbs::desc::event_id__cache_comp__size
{
{ "name", "ircd.m.dbs.event_id.cache_comp.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "event_id"_>()));
const size_t &value{event_id__cache_comp__size};
@ -144,7 +146,8 @@ ircd::m::dbs::desc::type__cache__size
{
{ "name", "ircd.m.dbs.type.cache.size" },
{ "default", long(64_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "type"_>()));
const size_t &value{type__cache__size};
@ -158,7 +161,8 @@ ircd::m::dbs::desc::type__cache_comp__size
{
{ "name", "ircd.m.dbs.type.cache_comp.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "type"_>()));
const size_t &value{type__cache_comp__size};
@ -228,7 +232,8 @@ ircd::m::dbs::desc::content__cache__size
{
{ "name", "ircd.m.dbs.content.cache.size" },
{ "default", long(64_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "content"_>()));
const size_t &value{content__cache__size};
@ -242,7 +247,8 @@ ircd::m::dbs::desc::content__cache_comp__size
{
{ "name", "ircd.m.dbs.content.cache_comp.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "content"_>()));
const size_t &value{content__cache_comp__size};
@ -329,7 +335,8 @@ ircd::m::dbs::desc::room_id__cache__size
{
{ "name", "ircd.m.dbs.room_id.cache.size" },
{ "default", long(32_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "room_id"_>()));
const size_t &value{room_id__cache__size};
@ -343,7 +350,8 @@ ircd::m::dbs::desc::room_id__cache_comp__size
{
{ "name", "ircd.m.dbs.room_id.cache_comp.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "room_id"_>()));
const size_t &value{room_id__cache_comp__size};
@ -412,7 +420,8 @@ ircd::m::dbs::desc::sender__cache__size
{
{ "name", "ircd.m.dbs.sender.cache.size" },
{ "default", long(32_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "sender"_>()));
const size_t &value{sender__cache__size};
@ -426,7 +435,8 @@ ircd::m::dbs::desc::sender__cache_comp__size
{
{ "name", "ircd.m.dbs.sender.cache_comp.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "sender"_>()));
const size_t &value{sender__cache_comp__size};
@ -495,7 +505,8 @@ ircd::m::dbs::desc::state_key__cache__size
{
{ "name", "ircd.m.dbs.state_key.cache.size" },
{ "default", long(32_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "state_key"_>()));
const size_t &value{state_key__cache__size};
@ -509,7 +520,8 @@ ircd::m::dbs::desc::state_key__cache_comp__size
{
{ "name", "ircd.m.dbs.state_key.cache_comp.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "state_key"_>()));
const size_t &value{state_key__cache_comp__size};
@ -580,7 +592,8 @@ ircd::m::dbs::desc::origin_server_ts__cache__size
{
{ "name", "ircd.m.dbs.origin_server_ts.cache.size" },
{ "default", long(32_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "origin_server_ts"_>()));
const size_t &value{origin_server_ts__cache__size};
@ -594,7 +607,8 @@ ircd::m::dbs::desc::origin_server_ts__cache_comp__size
{
{ "name", "ircd.m.dbs.origin_server_ts.cache_comp.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "origin_server_ts"_>()));
const size_t &value{origin_server_ts__cache_comp__size};
@ -664,7 +678,8 @@ ircd::m::dbs::desc::depth__cache__size
{
{ "name", "ircd.m.dbs.depth.cache.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "depth"_>()));
const size_t &value{depth__cache__size};
@ -678,7 +693,8 @@ ircd::m::dbs::desc::depth__cache_comp__size
{
{ "name", "ircd.m.dbs.depth.cache_comp.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
auto &column(event_column.at(json::indexof<event, "depth"_>()));
const size_t &value{depth__cache_comp__size};

View file

@ -38,7 +38,8 @@ ircd::m::dbs::desc::event_horizon__cache__size
{
{ "name", "ircd.m.dbs._event_horizon.cache.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_horizon__cache__size};
db::capacity(db::cache(dbs::event_horizon), value);
@ -51,7 +52,8 @@ ircd::m::dbs::desc::event_horizon__cache_comp__size
{
{ "name", "ircd.m.dbs._event_horizon.cache_comp.size" },
{ "default", long(0_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_horizon__cache_comp__size};
db::capacity(db::cache_compressed(dbs::event_horizon), value);

View file

@ -38,7 +38,8 @@ ircd::m::dbs::desc::event_idx__cache__size
{
{ "name", "ircd.m.dbs._event_idx.cache.size" },
{ "default", long(128_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_idx__cache__size};
db::capacity(db::cache(dbs::event_idx), value);
@ -51,7 +52,8 @@ ircd::m::dbs::desc::event_idx__cache_comp__size
{
{ "name", "ircd.m.dbs._event_idx.cache_comp.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_idx__cache_comp__size};
db::capacity(db::cache_compressed(dbs::event_idx), value);

View file

@ -38,7 +38,8 @@ ircd::m::dbs::desc::event_json__cache__size
{
{ "name", "ircd.m.dbs._event_json.cache.size" },
{ "default", long(128_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_json__cache__size};
db::capacity(db::cache(dbs::event_json), value);
@ -51,7 +52,8 @@ ircd::m::dbs::desc::event_json__cache_comp__size
{
{ "name", "ircd.m.dbs._event_json.cache_comp.size" },
{ "default", long(0_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_json__cache_comp__size};
db::capacity(db::cache_compressed(dbs::event_json), value);

View file

@ -59,7 +59,8 @@ ircd::m::dbs::desc::event_refs__cache__size
{
{ "name", "ircd.m.dbs._event_refs.cache.size" },
{ "default", long(32_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_refs__cache__size};
db::capacity(db::cache(dbs::event_refs), value);
@ -72,7 +73,8 @@ ircd::m::dbs::desc::event_refs__cache_comp__size
{
{ "name", "ircd.m.dbs._event_refs.cache_comp.size" },
{ "default", long(0_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_refs__cache_comp__size};
db::capacity(db::cache_compressed(dbs::event_refs), value);

View file

@ -38,7 +38,8 @@ ircd::m::dbs::desc::event_sender__cache__size
{
{ "name", "ircd.m.dbs._event_sender.cache.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_sender__cache__size};
db::capacity(db::cache(dbs::event_sender), value);
@ -51,7 +52,8 @@ ircd::m::dbs::desc::event_sender__cache_comp__size
{
{ "name", "ircd.m.dbs._event_sender.cache_comp.size" },
{ "default", long(0_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_sender__cache_comp__size};
db::capacity(db::cache_compressed(dbs::event_sender), value);

View file

@ -43,7 +43,8 @@ ircd::m::dbs::desc::event_state__cache__size
{
{ "name", "ircd.m.dbs._event_state.cache.size" },
{ "default", long(32_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_state__cache__size};
db::capacity(db::cache(dbs::event_state), value);
@ -56,7 +57,8 @@ ircd::m::dbs::desc::event_state__cache_comp__size
{
{ "name", "ircd.m.dbs._event_state.cache_comp.size" },
{ "default", long(0_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_state__cache_comp__size};
db::capacity(db::cache_compressed(dbs::event_state), value);

View file

@ -38,7 +38,8 @@ ircd::m::dbs::desc::event_type__cache__size
{
{ "name", "ircd.m.dbs._event_type.cache.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_type__cache__size};
db::capacity(db::cache(dbs::event_type), value);
@ -51,7 +52,8 @@ ircd::m::dbs::desc::event_type__cache_comp__size
{
{ "name", "ircd.m.dbs._event_type.cache_comp.size" },
{ "default", long(0_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{event_type__cache_comp__size};
db::capacity(db::cache_compressed(dbs::event_type), value);

View file

@ -44,7 +44,8 @@ ircd::m::dbs::desc::room_events__cache__size
{
{ "name", "ircd.m.dbs._room_events.cache.size" },
{ "default", long(32_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{room_events__cache__size};
db::capacity(db::cache(dbs::room_events), value);
@ -57,7 +58,8 @@ ircd::m::dbs::desc::room_events__cache_comp__size
{
{ "name", "ircd.m.dbs._room_events.cache_comp.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{room_events__cache_comp__size};
db::capacity(db::cache_compressed(dbs::room_events), value);

View file

@ -38,7 +38,8 @@ ircd::m::dbs::desc::room_head__cache__size
{
{ "name", "ircd.m.dbs._room_head.cache.size" },
{ "default", long(8_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{room_head__cache__size};
db::capacity(db::cache(dbs::room_head), value);

View file

@ -38,7 +38,8 @@ ircd::m::dbs::desc::room_joined__cache__size
{
{ "name", "ircd.m.dbs._room_joined.cache.size" },
{ "default", long(8_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{room_joined__cache__size};
db::capacity(db::cache(dbs::room_joined), value);
@ -51,7 +52,8 @@ ircd::m::dbs::desc::room_joined__cache_comp__size
{
{ "name", "ircd.m.dbs._room_joined.cache_comp.size" },
{ "default", long(8_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{room_joined__cache_comp__size};
db::capacity(db::cache_compressed(dbs::room_joined), value);

View file

@ -38,7 +38,8 @@ ircd::m::dbs::desc::room_state__cache__size
{
{ "name", "ircd.m.dbs._room_state.cache.size" },
{ "default", long(32_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{room_state__cache__size};
db::capacity(db::cache(dbs::room_state), value);
@ -51,7 +52,8 @@ ircd::m::dbs::desc::room_state__cache_comp__size
{
{ "name", "ircd.m.dbs._room_state.cache_comp.size" },
{ "default", long(8_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{room_state__cache_comp__size};
db::capacity(db::cache_compressed(dbs::room_state), value);

View file

@ -43,7 +43,8 @@ ircd::m::dbs::desc::room_state_space__cache__size
{
{ "name", "ircd.m.dbs._room_state_space.cache.size" },
{ "default", long(32_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{room_state_space__cache__size};
db::capacity(db::cache(dbs::room_state_space), value);
@ -56,7 +57,8 @@ ircd::m::dbs::desc::room_state_space__cache_comp__size
{
{ "name", "ircd.m.dbs._room_state_space.cache_comp.size" },
{ "default", long(8_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{room_state_space__cache_comp__size};
db::capacity(db::cache_compressed(dbs::room_state_space), value);

View file

@ -43,7 +43,8 @@ ircd::m::dbs::desc::room_type__cache__size
{
{ "name", "ircd.m.dbs._room_type.cache.size" },
{ "default", long(16_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{room_type__cache__size};
db::capacity(db::cache(dbs::room_type), value);
@ -56,7 +57,8 @@ ircd::m::dbs::desc::room_type__cache_comp__size
{
{ "name", "ircd.m.dbs._room_type.cache_comp.size" },
{ "default", long(8_MiB) },
}, []
},
[](conf::item<void> &)
{
const size_t &value{room_type__cache_comp__size};
db::capacity(db::cache_compressed(dbs::room_type), value);

View file

@ -549,7 +549,7 @@ ircd::m::homeserver::conf::conf(const struct opts &opts)
{
assert(item);
if(item->set_cb)
item->set_cb();
item->set_cb(*item);
}
catch(const std::exception &e)
{