Batch authoritative snapshots and bound rejected retreat fallback
This commit is contained in:
@@ -99,14 +99,22 @@ async function deliverEvents(){
|
||||
FROM acore_auth.azerothai_event_outbox
|
||||
WHERE delivered_at IS NULL AND kind='player.snapshot'
|
||||
AND created_at >= NOW() - INTERVAL 90 SECOND
|
||||
ORDER BY id ASC LIMIT ${Math.max(1,Math.floor(EVENT_BATCH/2))}`);
|
||||
ORDER BY id ASC LIMIT 64`);
|
||||
if(fresh.length){
|
||||
const payloads=fresh.map(([, ,hex])=>JSON.parse(Buffer.from(hex,'hex').toString('utf8')));
|
||||
const response=await backend('/api/bridge/ale/snapshots',{
|
||||
method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({payloads})
|
||||
});
|
||||
if(!response.ok)throw new Error(`snapshot batch HTTP ${response.status}: ${await response.text()}`);
|
||||
mysql(`UPDATE acore_auth.azerothai_event_outbox SET delivered_at=NOW(6) WHERE id IN (${fresh.map(row=>Number(row[0])).join(',')})`);
|
||||
}
|
||||
const batch=rows(`SELECT id,HEX(kind),HEX(payload)
|
||||
FROM acore_auth.azerothai_event_outbox
|
||||
WHERE delivered_at IS NULL
|
||||
${fresh.length?`AND id NOT IN (${fresh.map(row=>Number(row[0])).join(',')})`:''}
|
||||
ORDER BY CASE WHEN kind IN ('player.permanent-death','bridge.ready') THEN 0 WHEN kind IN ('player.whisper','player.chat') AND created_at >= NOW() - INTERVAL 90 SECOND THEN 1 ELSE 2 END, id
|
||||
LIMIT ${Math.max(1,EVENT_BATCH-fresh.length)}`);
|
||||
for(const [id,kindHex,payloadHex] of [...fresh,...batch]){
|
||||
LIMIT ${EVENT_BATCH}`);
|
||||
for(const [id,kindHex,payloadHex] of batch){
|
||||
const kind=Buffer.from(kindHex||'','hex').toString('utf8');
|
||||
const payloadText=Buffer.from(payloadHex||'','hex').toString('utf8');
|
||||
let payload;
|
||||
|
||||
Reference in New Issue
Block a user