mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-05 19:28:25 +00:00
refactor: extract no-reachability-cache flag name into a constant
This commit is contained in:
@@ -137,6 +137,10 @@ object GrapeRankCommand {
|
|||||||
|
|
||||||
private const val PROBE_TIMEOUT_MS = 2000
|
private const val PROBE_TIMEOUT_MS = 2000
|
||||||
|
|
||||||
|
// args.bool on a mistyped flag silently returns false, so the one flag read from
|
||||||
|
// three different functions goes through a compile-time-checked name.
|
||||||
|
private const val NO_REACHABILITY_CACHE_FLAG = "no-reachability-cache"
|
||||||
|
|
||||||
// The probe does BLOCKING DNS + TCP connect, and dead-domain DNS lookups can hang
|
// The probe does BLOCKING DNS + TCP connect, and dead-domain DNS lookups can hang
|
||||||
// far past the connect timeout. On the shared Dispatchers.IO those hanging lookups
|
// far past the connect timeout. On the shared Dispatchers.IO those hanging lookups
|
||||||
// starve the crawl's own IO — measured +462s on the finishing drain at hop-3. Run
|
// starve the crawl's own IO — measured +462s on the finishing drain at hop-3. Run
|
||||||
@@ -452,7 +456,7 @@ object GrapeRankCommand {
|
|||||||
// parallel storm at crawl start so the connect wait is paid once, up front.
|
// parallel storm at crawl start so the connect wait is paid once, up front.
|
||||||
// The crawl's own final live/dead set is flushed back by the caller.
|
// The crawl's own final live/dead set is flushed back by the caller.
|
||||||
val reachability =
|
val reachability =
|
||||||
if (args.bool("no-reachability-cache")) null else ctx.reachability.snapshot()
|
if (args.bool(NO_REACHABILITY_CACHE_FLAG)) null else ctx.reachability.snapshot()
|
||||||
val knownDead = reachability?.dead ?: emptySet()
|
val knownDead = reachability?.dead ?: emptySet()
|
||||||
// Mass pre-connect sizing: every warm socket is one FD, so the default is
|
// Mass pre-connect sizing: every warm socket is one FD, so the default is
|
||||||
// derived from the process's ulimit (--preconnect-cap to override,
|
// derived from the process's ulimit (--preconnect-cap to override,
|
||||||
@@ -529,7 +533,7 @@ object GrapeRankCommand {
|
|||||||
args: Args,
|
args: Args,
|
||||||
stats: GrapeRankCrawler.Stats,
|
stats: GrapeRankCrawler.Stats,
|
||||||
) {
|
) {
|
||||||
if (args.bool("no-reachability-cache")) return
|
if (args.bool(NO_REACHABILITY_CACHE_FLAG)) return
|
||||||
runCatching {
|
runCatching {
|
||||||
ctx.reachability.record(reachable = stats.liveRelays, dead = stats.deadRelays)
|
ctx.reachability.record(reachable = stats.liveRelays, dead = stats.deadRelays)
|
||||||
System.err.println(
|
System.err.println(
|
||||||
@@ -699,7 +703,7 @@ object GrapeRankCommand {
|
|||||||
// Live author-advertised relays are always synced (--no-reachability-cache
|
// Live author-advertised relays are always synced (--no-reachability-cache
|
||||||
// to reconcile every relay regardless).
|
// to reconcile every relay regardless).
|
||||||
val knownDead =
|
val knownDead =
|
||||||
if (args.bool("no-reachability-cache")) emptySet() else ctx.reachability.snapshot().dead
|
if (args.bool(NO_REACHABILITY_CACHE_FLAG)) emptySet() else ctx.reachability.snapshot().dead
|
||||||
|
|
||||||
val updater =
|
val updater =
|
||||||
GrapeRankUpdater(
|
GrapeRankUpdater(
|
||||||
|
|||||||
Reference in New Issue
Block a user