0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-16 01:26:58 +01:00

modules/client/sync: Pack the upper-bound into the phased polylog since token.

This commit is contained in:
Jason Volk 2019-07-06 21:58:57 -07:00
parent 49264bd13b
commit 6fb6f096de
2 changed files with 29 additions and 3 deletions
modules/client

View file

@ -442,11 +442,32 @@ try
int64_t(data.range.second) int64_t(data.range.second)
}; };
char buf[48];
const string_view &next_batch_token
{
// The polylog phased since token. We pack two numbers separted by a '_'
// character which cannot be urlencoded atm. The first is the usual
// since token integer, which is negative for phased initial sync. The
// second part is the next_batch upper-bound integer which is a snapshot
// of the server's sequence number when the phased sync started.
data.phased?
fmt::sprintf
{
buf, "%ld_%lu", next_batch, data.range.second
}:
// The normal integer since token.
fmt::sprintf
{
buf, "%ld", next_batch
}
};
json::stack::member json::stack::member
{ {
*data.out, "next_batch", json::value *data.out, "next_batch", json::value
{ {
lex_cast(next_batch), json::STRING next_batch_token ,json::STRING
} }
}; };
} }

View file

@ -26,10 +26,15 @@ struct ircd::m::sync::args
request.query["filter"] request.query["filter"]
}; };
std::pair<string_view, string_view> since_token
{
split(request.query.get("since", "0"_sv), '_')
};
uint64_t since uint64_t since
{ {
// 6.2.1 A point in time to continue a sync from. // 6.2.1 A point in time to continue a sync from.
request.query.get<uint64_t>("since", 0) lex_cast<uint64_t>(since_token.first)
}; };
uint64_t next_batch uint64_t next_batch
@ -41,7 +46,7 @@ struct ircd::m::sync::args
// time. But that would be nice. Many sync modules do not support this // time. But that would be nice. Many sync modules do not support this
// because the results of repeated calls for range may become empty // because the results of repeated calls for range may become empty
// after a while. // after a while.
request.query.get<uint64_t>("next_batch", -1) uint64_t(lex_cast<int64_t>(request.query.get("next_batch", since_token.second?: "-1"_sv)))
}; };
steady_point timesout{[this] steady_point timesout{[this]