Conversation
… 트래픽 처리 도중 공유풀 임계치 확인 및 알람 생성
Fix/traffic logic junha
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (57)
📝 WalkthroughWalkthroughThis PR introduces shared pool threshold alarm notifications, policy-check Lua script separation, family metadata caching with write-through synchronization, and comprehensive k6 load testing infrastructure for 100-line and 1000-line traffic scenarios. It extends traffic deduction logic with whitelist bypass flags, idempotent refill handling, and multi-stage policy application. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant TrafficDeductOrch as TrafficDeductOrchestratorService
participant HydrateAdapter as TrafficHydrateRefillAdapterService
participant LuaScripts as Lua Scripts (Redis)
participant ThresholdAlarm as TrafficSharedPoolThresholdAlarmService
participant Outbox as RedisOutboxRecordService
participant FamilyCache as TrafficFamilyMetaCacheService
Client->>TrafficDeductOrch: executeSharedWithRecovery(payload)
TrafficDeductOrch->>HydrateAdapter: executeSharedWithRecovery(payload, amount)
HydrateAdapter->>LuaScripts: executePolicyCheckShared(keys, args)
LuaScripts-->>HydrateAdapter: {answer: 0/1, status: OK/BLOCKED/HYDRATE}
alt policy_check OK
HydrateAdapter->>LuaScripts: executeDeductShared(keys, args, whitelist_bypass_flag, refill_amount)
LuaScripts-->>HydrateAdapter: {answer, final_status, remaining}
HydrateAdapter-->>TrafficDeductOrch: result
end
alt shared deduction > 0
TrafficDeductOrch->>ThresholdAlarm: checkAndEnqueueIfReached(familyId)
ThresholdAlarm->>FamilyCache: getOrLoad(familyId)
FamilyCache-->>ThresholdAlarm: TrafficFamilyMetaSnapshot
ThresholdAlarm->>ThresholdAlarm: computeRemainingPercent()
loop for each threshold (50, 30, 10, custom)
alt threshold reached
ThresholdAlarm->>Outbox: createPending(SHARED_POOL_THRESHOLD_REACHED, payload)
Outbox-->>ThresholdAlarm: success
end
end
ThresholdAlarm-->>TrafficDeductOrch: (callback completes)
end
TrafficDeductOrch-->>Client: result
sequenceDiagram
participant Consumer as TrafficStreamConsumerRunner
participant DbFallback as TrafficDbDeductFallbackService
participant WriteThrough as TrafficBalanceStateWriteThroughService
participant Cache as TrafficFamilyMetaCacheService
participant FamilyMeta as Family Meta (Redis)
Consumer->>DbFallback: executeSharedWithRecovery(payload, amount, context)
DbFallback->>DbFallback: computePolicyCappedTarget(daily, shared, app_daily, app_speed)
DbFallback->>DbFallback: deductFromDb()
alt poolType = SHARED and familyId present
DbFallback->>WriteThrough: markSharedMetaContribution(familyId, amount)
WriteThrough->>Cache: increaseTotalAndDbRemaining(familyId, amount)
Cache->>FamilyMeta: HSET pool_total_data, db_remaining_data
end
DbFallback-->>Consumer: TrafficDeductResultResDto
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
|
개요
관련 BackLog
Resolves: (Backlog Number, ...)
PR 유형
PR Checklist
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Chores