0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd:Ⓜ️:sync: Move definitions to module.

ircd:Ⓜ️:sync: Give sync::data an instance_list.
This commit is contained in:
Jason Volk 2019-07-06 20:17:42 -07:00
parent c6a9cf3849
commit 18f07b6378
4 changed files with 132 additions and 83 deletions

View file

@ -73,6 +73,7 @@ struct ircd::m::sync::item
};
struct ircd::m::sync::data
:instance_list<ircd::m::sync::data>
{
/// Range to synchronize. Starting index is inclusive, ending index is
/// exclusive. Generally the starting index is a since token, and ending

135
ircd/m.cc
View file

@ -695,10 +695,22 @@ ircd::m::sync::stats_info
};
template<>
decltype(ircd::m::sync::item::instance_multimap::map)
ircd::m::sync::item::instance_multimap::map
decltype(ircd::util::instance_multimap<std::string, ircd::m::sync::item, std::less<>>::map)
ircd::util::instance_multimap<std::string, ircd::m::sync::item, std::less<>>::map
{};
template<>
decltype(ircd::util::instance_list<ircd::m::sync::data>::allocator)
ircd::util::instance_list<ircd::m::sync::data>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::m::sync::data>::list)
ircd::util::instance_list<ircd::m::sync::data>::list
{
allocator
};
bool
ircd::m::sync::for_each(const item_closure_bool &closure)
{
@ -819,67 +831,6 @@ ircd::m::sync::loghead(const data &data)
};
}
//
// data
//
ircd::m::sync::data::data
(
const m::user &user,
const m::events::range &range,
ircd::client *const &client,
json::stack *const &out,
sync::stats *const &stats,
const string_view &filter_id
)
:range
{
range
}
,stats
{
stats
}
,client
{
client
}
,user
{
user
}
,user_room
{
user
}
,user_state
{
user_room
}
,user_rooms
{
user
}
,filter_buf
{
m::filter::get(filter_id, user)
}
,filter
{
json::object{filter_buf}
}
,out
{
out
}
{
}
ircd::m::sync::data::~data()
noexcept
{
}
//
// item
//
@ -1133,6 +1084,64 @@ const
return this->instance_multimap::it->first;
}
//
// data
//
ircd::m::sync::data::data(const m::user &user,
const m::events::range &range,
ircd::client *const &client,
json::stack *const &out,
sync::stats *const &stats,
const string_view &filter_id)
:range
{
range
}
,stats
{
stats
}
,client
{
client
}
,user
{
user
}
,user_room
{
user
}
,user_state
{
user_room
}
,user_rooms
{
user
}
,filter_buf
{
m::filter::get(filter_id, user)
}
,filter
{
json::object{filter_buf}
}
,out
{
out
}
{
}
ircd::m::sync::data::~data()
noexcept
{
}
///////////////////////////////////////////////////////////////////////////////
//
// m/app.h

View file

@ -144,26 +144,6 @@ ircd::m::sync::args::timeout_default
{ "default", 90 * 1000L },
};
//
// args::args
//
ircd::m::sync::args::args(const resource::request &request)
try
:request
{
request
}
{
}
catch(const bad_lex_cast &e)
{
throw m::BAD_REQUEST
{
"Since parameter invalid :%s", e.what()
};
}
//
// GET sync
//
@ -837,3 +817,23 @@ ircd::m::sync::longpoll::handle(data &data,
return true;
}
//
// args::args
//
ircd::m::sync::args::args(const resource::request &request)
try
:request
{
request
}
{
}
catch(const bad_lex_cast &e)
{
throw m::BAD_REQUEST
{
"Since parameter invalid :%s", e.what()
};
}

View file

@ -5406,6 +5406,45 @@ console_cmd__client__spawn(opt &out, const string_view &line)
return true;
}
bool
console_cmd__client__sync(opt &out, const string_view &line)
{
for(auto *const &data_p : m::sync::data::list)
{
const auto *const &client(data_p->client);
if(client)
out << client->loghead() << " < ";
out << m::sync::loghead(*data_p) << " | ";
out << std::endl;
}
return true;
}
bool
console_cmd__client__sync__item(opt &out, const string_view &line)
{
const params param{line, " ",
{
"prefix"
}};
const auto prefix
{
param.at("prefix", ""_sv)
};
ircd::m::sync::for_each(prefix, [&out]
(const auto &item)
{
out << item.name() << std::endl;
return true;
});
return true;
}
//
// resource
//