Skip to content

Commit

Permalink
Merge pull request #35 from ckcr4lyf/patch/update-announce-time
Browse files Browse the repository at this point in the history
Add the ZADDS
  • Loading branch information
ckcr4lyf authored May 17, 2023
2 parents 92611e8 + 3bc5b6c commit 4ebccd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,5 @@ jobs:
uses: docker://ghcr.io/ckcr4lyf/kiryuu-gauge:master
env:
KIRYUU_HOST: http://172.17.0.1:6969
REDIS_HOST: redis://172.17.0.1:6379
REDIS_HOST: redis://172.17.0.1:6379
ANNOUNCE_IP_PORT: AC120003115C #172.18.0.3:4444 <- This is the IP kiryuu will see the announce come from, so what we need to hardcode in redis via Gauge
13 changes: 9 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ async fn announce(req: HttpRequest, data: web::Data<AppState>) -> HttpResponse {
post_announce_pipeline.cmd("ZREM").arg(&leechers_key).arg(&parsed.ip_port).ignore(); // We dont care about the return value
}
} else if parsed.is_seeding {
// ZADD it regardless to update timestamp for the guy (in redis)
post_announce_pipeline.cmd("ZADD").arg(&seeders_key).arg(time_now_ms).arg(&parsed.ip_port).ignore();

// New seeder
if let Exists::No = is_seeder_v2 {
post_announce_pipeline.cmd("ZADD").arg(&seeders_key).arg(time_now_ms).arg(&parsed.ip_port).ignore();
seed_count_mod += 1;
}

Expand All @@ -119,10 +120,14 @@ async fn announce(req: HttpRequest, data: web::Data<AppState>) -> HttpResponse {
// Increment the downloaded count for the infohash stats
post_announce_pipeline.cmd("HINCRBY").arg(&parsed.info_hash).arg("downloaded").arg(1u32).ignore();
}
} else if let Exists::No = is_leecher_v2 {
post_announce_pipeline.cmd("ZADD").arg(&leechers_key).arg(time_now_ms).arg(&parsed.ip_port).ignore();
} else {
// ZADD it regardless to update timestamp for the guy (in redis)
post_announce_pipeline.cmd("ZADD").arg(&leechers_key).arg(time_now_ms).arg(&parsed.ip_port).ignore();

if let Exists::No = is_leecher_v2 {
leech_count_mod += 1;
};
};
}

// Cache miss = query redis
// no change = update cache
Expand Down

0 comments on commit 4ebccd0

Please sign in to comment.