platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
118
selective-vpn-api/app/resolver_bridge_pipeline_planning.go
Normal file
118
selective-vpn-api/app/resolver_bridge_pipeline_planning.go
Normal file
@@ -0,0 +1,118 @@
|
||||
package app
|
||||
|
||||
import resolverpkg "selective-vpn-api/app/resolver"
|
||||
|
||||
func buildResolverPlanning(
|
||||
domains []string,
|
||||
now int,
|
||||
ttl int,
|
||||
precheckDue bool,
|
||||
precheckMaxDomains int,
|
||||
staleKeepSec int,
|
||||
negTTLNX int,
|
||||
negTTLTimeout int,
|
||||
negTTLTemporary int,
|
||||
negTTLOther int,
|
||||
domainCache *domainCacheState,
|
||||
cacheSourceForHost func(string) domainCacheSource,
|
||||
logf func(string, ...any),
|
||||
) resolverPlanningResult {
|
||||
sourceFn := func(host string) resolverpkg.DomainCacheSource {
|
||||
if cacheSourceForHost == nil {
|
||||
return resolverpkg.DomainCacheSourceDirect
|
||||
}
|
||||
return resolverpkg.DomainCacheSource(cacheSourceForHost(host))
|
||||
}
|
||||
return resolverpkg.BuildResolvePlanning(
|
||||
resolverpkg.ResolvePlanningInput{
|
||||
Domains: domains,
|
||||
Now: now,
|
||||
TTL: ttl,
|
||||
PrecheckDue: precheckDue,
|
||||
PrecheckMaxDomains: precheckMaxDomains,
|
||||
StaleKeepSec: staleKeepSec,
|
||||
NegTTLNX: negTTLNX,
|
||||
NegTTLTimeout: negTTLTimeout,
|
||||
NegTTLTemporary: negTTLTemporary,
|
||||
NegTTLOther: negTTLOther,
|
||||
},
|
||||
(*resolverpkg.DomainCacheState)(domainCache),
|
||||
sourceFn,
|
||||
logf,
|
||||
)
|
||||
}
|
||||
|
||||
func finalizeResolverPrecheck(
|
||||
precheckDue bool,
|
||||
precheckStatePath string,
|
||||
now int,
|
||||
timeoutRecheck resolverTimeoutRecheckStats,
|
||||
liveBatchTarget int,
|
||||
liveBatchMin int,
|
||||
liveBatchMax int,
|
||||
liveBatchNXHeavyPct int,
|
||||
liveBatchNXHeavyMin int,
|
||||
liveBatchNXHeavyMax int,
|
||||
dnsStats dnsMetrics,
|
||||
liveDeferred int,
|
||||
resolvedNowDNS int,
|
||||
liveP1 int,
|
||||
liveP2 int,
|
||||
liveP3 int,
|
||||
liveNXHeavyTotal int,
|
||||
liveNXHeavySkip int,
|
||||
toResolveTotal int,
|
||||
precheckFileForced bool,
|
||||
precheckForcePath string,
|
||||
logf func(string, ...any),
|
||||
) resolverpkg.ResolverPrecheckFinalizeResult {
|
||||
return resolverpkg.FinalizeResolverPrecheck(
|
||||
resolverpkg.ResolverPrecheckFinalizeInput{
|
||||
PrecheckDue: precheckDue,
|
||||
PrecheckStatePath: precheckStatePath,
|
||||
Now: now,
|
||||
TimeoutRecheck: timeoutRecheck,
|
||||
LiveBatchTarget: liveBatchTarget,
|
||||
LiveBatchMin: liveBatchMin,
|
||||
LiveBatchMax: liveBatchMax,
|
||||
LiveBatchNXHeavyPct: liveBatchNXHeavyPct,
|
||||
LiveBatchNXHeavyMin: liveBatchNXHeavyMin,
|
||||
LiveBatchNXHeavyMax: liveBatchNXHeavyMax,
|
||||
DNSStats: dnsStats,
|
||||
LiveDeferred: liveDeferred,
|
||||
ResolvedNowDNS: resolvedNowDNS,
|
||||
LiveP1: liveP1,
|
||||
LiveP2: liveP2,
|
||||
LiveP3: liveP3,
|
||||
LiveNXHeavyTotal: liveNXHeavyTotal,
|
||||
LiveNXHeavySkip: liveNXHeavySkip,
|
||||
ToResolveTotal: toResolveTotal,
|
||||
PrecheckFileForced: precheckFileForced,
|
||||
PrecheckForcePath: precheckForcePath,
|
||||
},
|
||||
logf,
|
||||
)
|
||||
}
|
||||
|
||||
func buildResolverRuntimeTuning(opts ResolverOpts, now int, precheckStatePath string, precheckEnvForced bool, precheckFileForced bool) resolverRuntimeTuning {
|
||||
return resolverpkg.BuildResolverRuntimeTuning(
|
||||
resolverpkg.ResolverRuntimeTuningInput{
|
||||
TTL: opts.TTL,
|
||||
Workers: opts.Workers,
|
||||
Now: now,
|
||||
PrecheckStatePath: precheckStatePath,
|
||||
PrecheckEnvForced: precheckEnvForced,
|
||||
PrecheckFileForced: precheckFileForced,
|
||||
},
|
||||
resolverpkg.ResolverRuntimeTuningDeps{
|
||||
EnvInt: envInt,
|
||||
LoadResolverPrecheckLastRun: loadResolverPrecheckLastRun,
|
||||
LoadResolverLiveBatchTarget: loadResolverLiveBatchTarget,
|
||||
LoadResolverLiveBatchNXHeavyPct: loadResolverLiveBatchNXHeavyPct,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func logResolverStart(input resolverStartLogInput, logf func(string, ...any)) {
|
||||
resolverpkg.LogResolverStart(input, logf)
|
||||
}
|
||||
Reference in New Issue
Block a user