0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-01 00:08:22 +02:00

ircd:Ⓜ️:sync: Make instance-level conf::items for all sync::items.

This commit is contained in:
Jason Volk 2019-02-22 17:05:28 -08:00
parent 603cc98e30
commit ec50b0f76e
3 changed files with 26 additions and 13 deletions

View file

@ -37,7 +37,6 @@ namespace ircd::m::sync
extern log::log log; extern log::log log;
extern ctx::pool pool; extern ctx::pool pool;
extern conf::item<bool> stats_info; extern conf::item<bool> stats_info;
extern conf::item<bool> stats_debug;
} }
struct ircd::m::sync::item struct ircd::m::sync::item
@ -45,6 +44,9 @@ struct ircd::m::sync::item
{ {
using handle = std::function<void (data &)>; using handle = std::function<void (data &)>;
std::string conf_name[2];
conf::item<bool> enable;
conf::item<bool> stats_debug;
handle _polylog; handle _polylog;
handle _linear; handle _linear;

View file

@ -426,13 +426,6 @@ ircd::m::sync::stats_info
{ "default", false }, { "default", false },
}; };
decltype(ircd::m::sync::stats_debug)
ircd::m::sync::stats_debug
{
{ "name", "ircd.m.sync.stats.debug" },
{ "default", false },
};
bool bool
ircd::m::sync::for_each(const item_closure_bool &closure) ircd::m::sync::for_each(const item_closure_bool &closure)
{ {
@ -644,6 +637,21 @@ ircd::m::sync::item::item(std::string name,
{ {
std::move(name) std::move(name)
} }
,conf_name
{
fmt::snstringf{128, "ircd.m.sync.%s.enable", this->name()},
fmt::snstringf{128, "ircd.m.sync.%s.stats.debug", this->name()},
}
,enable
{
{ "name", conf_name[0] },
{ "default", true },
}
,stats_debug
{
{ "name", conf_name[1] },
{ "default", false },
}
,_polylog ,_polylog
{ {
std::move(polylog) std::move(polylog)
@ -676,22 +684,25 @@ void
ircd::m::sync::item::polylog(data &data) ircd::m::sync::item::polylog(data &data)
try try
{ {
if(!enable)
return;
#ifdef RB_DEBUG #ifdef RB_DEBUG
sync::stats stats sync::stats stats
{ {
data.stats? data.stats && (stats_info || stats_debug)?
*data.stats: *data.stats:
sync::stats{} sync::stats{}
}; };
if(data.stats) if(data.stats && (stats_info || stats_debug))
stats.timer = {}; stats.timer = {};
#endif #endif
_polylog(data); _polylog(data);
#ifdef RB_DEBUG #ifdef RB_DEBUG
if(data.stats && bool(stats_debug)) if(data.stats && (stats_info || stats_debug))
{ {
//data.out.flush(); //data.out.flush();
thread_local char tmbuf[32]; thread_local char tmbuf[32];

View file

@ -93,7 +93,7 @@ ircd::m::sync::_rooms_polylog(data &data,
data.user_rooms.for_each(membership, [&data] data.user_rooms.for_each(membership, [&data]
(const m::room &room, const string_view &membership_) (const m::room &room, const string_view &membership_)
{ {
#ifdef RB_DEBUG #if defined(RB_DEBUG) && 0
sync::stats stats sync::stats stats
{ {
data.stats? data.stats?
@ -107,7 +107,7 @@ ircd::m::sync::_rooms_polylog(data &data,
_rooms_polylog_room(data, room); _rooms_polylog_room(data, room);
#ifdef RB_DEBUG #if defined(RB_DEBUG) && 0
thread_local char tmbuf[32]; thread_local char tmbuf[32];
if(data.stats && bool(stats_debug)) log::debug if(data.stats && bool(stats_debug)) log::debug
{ {