Skip to content

Commit 5eb1e70

Browse files
committed
redisq references -> r2 references
1 parent 6bd62db commit 5eb1e70

11 files changed

Lines changed: 37 additions & 37 deletions

File tree

DEBUGGING_ROUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Killmails are being posted to the wrong guildId/channelId despite the filter mat
66
## How the System Works
77

88
### Data Flow
9-
1. **poll-redisq.js** polls for new killmails
9+
1. **poll-r2.js** polls for new killmails
1010
2. For each killmail, it queries MongoDB for matching subscriptions
1111
3. Each subscription document contains: `{ guildId, channelId, entityIds, labels, iskValue, advanced }`
1212
4. When a match is found, it extracts `channelId` and `guildId` from the matched document
@@ -92,7 +92,7 @@ The `match` object is never mutated after being retrieved from MongoDB:
9292

9393
### Queue Processing
9494
```javascript
95-
// poll-redisq.js - pushing to queue
95+
// poll-r2.js - pushing to queue
9696
const channelId = match.channelId;
9797
const guildId = match.guildId;
9898
discord_posts_queue.push({ db, match, guildId, channelId, killmail, zkb, colorCode, matchType });

Privacy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ If the Bot is removed from a Discord server, all related configuration and histo
5656

5757
zKillBot interacts with:
5858
- **EVE Online / CCP Games** — to retrieve killmail and entity information.
59-
- **https://zkillredisq.stream/** - [RedisQ](https://github.com/zKillboard/RedisQ) for polling of killmails that have been retrieved via https://zkillboard.com
59+
- **https://r2z2.zkillboard.com/sequence/*.json** zkill's R2 for polling of killmails via sequences
6060
- **Discord** — to send and receive data via the Discord API.
6161

6262
All EVE Online intellectual property, including names, logos, and related materials, are the property of **CCP Games**.

docs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ <h5 class="card-title" style="color: #d9534f;">Enhanced Links</h5>
334334
<div class="card-body">
335335
<i class="bi bi-lightning-fill feature-icon"></i>
336336
<h4 class="mb-3">Real-time Updates</h4>
337-
<p class="card-text">Receive killmails as they happen using zKillboard's RedisQ stream with minimal latency.</p>
337+
<p class="card-text">Receive killmails as they happen using zKillboard's R2 with minimal latency.</p>
338338
</div>
339339
</div>
340340
</div>
@@ -590,7 +590,7 @@ <h2 class="mb-4">Important Notes</h2>
590590
<div class="card">
591591
<div class="card-body">
592592
<ul>
593-
<li>zKillBot uses RedisQ to stream killmails from zKillBoard in near real-time.</li>
593+
<li>zKillBot uses R2 to poll killmails from zKillBoard in near real-time.</li>
594594
<li>If a name query matches multiple results, zKillBot will list the IDs so you can subscribe by ID or refine your search.</li>
595595
<li>A channel may have multiple subscriptions.</li>
596596
<li>Each killmail will only be posted once per channel, even if it matches multiple subscriptions.</li>

env.example

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
REDISQ_URL=https://zkillredisq.stream/listen.php?queueID=
2-
31
# Set to development and the bot will assign GUILD_ID too for instant slash command updates
42
NODE_ENV=
53
# Be sure to invite the bot to your server first.... (see INVITE below)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"keywords": [],
1212
"author": "",
1313
"license": "Unlicense",
14-
"description": "A simple bot that listens to zKillboard's RedisQ for killmails and posts to Discord.",
14+
"description": "A simple bot that listens to zKillboard's R2 for killmails and posts to Discord.",
1515
"engines": {
1616
"node": ">=22"
1717
},
Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,49 @@ let pollIntervalId = null;
99

1010
let errorCount = 0;
1111

12-
export async function pollRedisQ(db, REDISQ_URL, sequence = 0) {
12+
export async function pollR2(db, sequence = 0) {
1313
if (app_status.exiting) {
14-
app_status.redisq_polling = false;
14+
app_status.r2_polling = false;
1515
if (pollIntervalId) {
1616
clearTimeout(pollIntervalId);
1717
pollIntervalId = null;
1818
}
1919
return;
2020
}
2121

22-
let wait = 10000; // Default to being slow if there is no data
22+
let wait = 6666; // Default to being slow if there is no data
2323
let timer = null;
2424
try {
2525
if (discord_posts_queue.length > 100) {
26-
// we'll wait the default timeout
26+
wait = 1111; // If our queue is backed up, slow down polling to give it a chance to catch up
2727
return;
2828
}
2929

3030
if (sequence == 0) {
3131
const row = await db.keyvalues.findOne({ key: "sequence" });
3232
sequence = row?.value || 0;
3333

34-
// Ensure we have a valid starting sequence
35-
const testRes = await fetch(`https://r2z2.zkillboard.com/ephemeral/${sequence}.json`, {
36-
headers: HEADERS.headers
37-
});
38-
if (testRes.status === 404 && sequence > 0) {
39-
console.log(`Stored RedisQ sequence ${sequence} is invalid, resetting to 0`);
40-
sequence = 0;
34+
if (sequence > 0) {
35+
// Ensure we have a valid starting sequence
36+
const testRes = await fetch(`https://r2z2.zkillboard.com/ephemeral/${sequence}.json`, {
37+
headers: HEADERS.headers
38+
});
39+
if (testRes.status === 404 && sequence > 0) {
40+
console.log(`Stored R2 sequence ${sequence} is invalid, resetting to 0`);
41+
sequence = 0;
42+
}
4143
}
4244

4345
if (sequence == 0) {
4446
const raw = await fetchWithRetry("https://r2z2.zkillboard.com/ephemeral/sequence.json");
4547
const seqData = await raw.json();
4648
sequence = seqData.sequence || 0;
4749
if (sequence == 0) {
48-
console.error("Failed to get initial RedisQ sequence number, defaulting to 0");
50+
console.error("Failed to get initial R2 sequence number, defaulting to 0");
4951
return;
5052
}
5153
}
52-
console.log(`Starting RedisQ sequence at ${sequence}`);
54+
console.log(`Starting R2 sequence at ${sequence}`);
5355
}
5456

5557
let controller = new AbortController();
@@ -62,6 +64,7 @@ export async function pollRedisQ(db, REDISQ_URL, sequence = 0) {
6264
clearTimeout(timer);
6365
timer = null;
6466
controller = null; // Release AbortController reference
67+
console.log(new Date(), res.status, `https://r2z2.zkillboard.com/ephemeral/${sequence}.json`);
6568

6669
if (res.status !== 200) {
6770
errorCount++;
@@ -252,11 +255,11 @@ export async function pollRedisQ(db, REDISQ_URL, sequence = 0) {
252255
}
253256
}
254257

255-
app_status.redisq_count++;
258+
app_status.r2_count++;
256259
}
257260

258261
if (data.sequence_id) {
259-
wait = 50;
262+
wait = 150;
260263
sequence++;
261264
await db.keyvalues.updateOne(
262265
{ key: "sequence" },
@@ -268,13 +271,13 @@ export async function pollRedisQ(db, REDISQ_URL, sequence = 0) {
268271
if (err.name === "AbortError") {
269272
console.error("Fetch timed out after 15 seconds");
270273
} else {
271-
console.error("Error polling RedisQ:", err);
274+
console.error("Error polling R2:", err);
272275
}
273276
} finally {
274277
if (timer) {
275278
clearTimeout(timer);
276279
timer = null;
277280
}
278-
pollIntervalId = setTimeout(() => pollRedisQ(db, REDISQ_URL, sequence), wait);
281+
pollIntervalId = setTimeout(() => pollR2(db, sequence), wait);
279282
}
280283
}

src/util/app-status.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { discord_posts_queue } from "../services/discord-post.js";
22

33
export let app_status = {
4-
redisq_count: 0,
4+
r2_count: 0,
55
discord_post_count: 0,
6-
redisq_polling: true,
6+
r2_polling: true,
77
exiting: false
88
};
99

1010
let statusIntervalId = null;
1111

1212
export function shareAppStatus() {
1313
const line = "📡" +
14-
" RedisQ polls:".padEnd(20) + String(app_status.redisq_count).padStart(5) +
14+
"R2 polls:".padEnd(20) + String(app_status.r2_count).padStart(5) +
1515
" Discord Queue:".padEnd(20) + String(discord_posts_queue.length).padStart(5) +
1616
" Discord Posts:".padEnd(20) + String(app_status.discord_post_count).padStart(5);
1717

1818
console.info(line);
1919

20-
app_status.redisq_count = 0;
20+
app_status.r2_count = 0;
2121
app_status.discord_post_count = 0;
2222

2323
if (statusIntervalId) clearTimeout(statusIntervalId);

src/util/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { readFileSync } from 'fs';
22

33
const pkg = JSON.parse(readFileSync("./package.json", "utf8"));
44
const { name, version } = pkg;
5-
export const ZKILLBOT_VERSION = `${name} v${version}`;
5+
export const ZKILLBOT_VERSION = `${name} v${version}` + (process.env.NODE_ENV !== "production" ? " (dev)" : "");
66

77
export const LOCALE = 'en';
88

src/util/shutdown.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ async function gracefulShutdown(signal) {
1818

1919
console.log(`⏹️ Preparing to shut down on ${signal}...`);
2020

21-
// wait for redisq_polling to finish and queue to drain (with 10s timeout)
21+
// wait for r2 polling to finish and queue to drain (with 10s timeout)
2222
const shutdownTimeout = Date.now() + 30000;
23-
while ((app_status.redisq_polling || discord_posts_queue.length > 0) && Date.now() < shutdownTimeout) {
23+
while ((app_status.r2_polling || discord_posts_queue.length > 0) && Date.now() < shutdownTimeout) {
2424
await sleep(100);
2525
}
2626

src/zkillbot.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { writeHeapSnapshot } from "v8";
1717
// @ts-ignore
1818
dotenv.config({ quiet: true, path: new URL("../.env", import.meta.url).pathname });
1919

20-
import { pollRedisQ } from "./services/poll-redisq.js";
20+
import { pollR2 } from "./services/poll-r2.js";
2121

2222
import "./util/shutdown.js";
2323

@@ -27,7 +27,7 @@ import { Db } from "mongodb";
2727
import { error } from "console";
2828
console.log(ZKILLBOT_VERSION);
2929

30-
const { DISCORD_BOT_TOKEN, CLIENT_ID, MONGO_URI, MONGO_DB, REDISQ_URL } = process.env;
30+
const { DISCORD_BOT_TOKEN, CLIENT_ID, MONGO_URI, MONGO_DB } = process.env;
3131
export const { ZKILLBOT_CHANNEL_WEBHOOK } = process.env;
3232

3333
// Memory debugging utilities
@@ -165,7 +165,7 @@ function startMemoryMonitoring() {
165165
setTimeout(() => logMemoryUsage(), 5000);
166166
}
167167

168-
if (!DISCORD_BOT_TOKEN || !CLIENT_ID || !REDISQ_URL || !MONGO_URI || !MONGO_DB) {
168+
if (!DISCORD_BOT_TOKEN || !CLIENT_ID || !MONGO_URI || !MONGO_DB) {
169169
console.error("❌ Missing required env vars");
170170
process.exit(1);
171171
}
@@ -233,7 +233,7 @@ async function init() {
233233
// Start memory monitoring
234234
//startMemoryMonitoring();
235235

236-
pollRedisQ(client.db, REDISQ_URL);
236+
pollR2(client.db);
237237
initCrons(client.db, client);
238238
});
239239

0 commit comments

Comments
 (0)