Copied to your clipboard
fun addAssetEvent(event: Event)
├─> assetHitProcessor.accumulateEvent(event)
├─> persistEventImmediately(event, queue)
└─> checkAndFlushIfNeeded()
suspend fun performFlush()
├─> val events = assetHitProcessor.processAccumulatedEvents()
└─> [Orchestrator processes events → dispatches to Edge]
└─> Edge guarantees delivery from here
Copied to your clipboard
func addAssetEvent(_ event: Event)
├─> assetHitProcessor.accumulateEvent(event)
├─> persistEventImmediately(event, to: queue)
└─> checkAndFlushIfNeeded()
func performFlush()
├─> let events = assetHitProcessor.processAccumulatedEvents()
└─> [Orchestrator processes events → dispatches to Edge]
└─> Edge guarantees delivery from here
Copied to your clipboard
override suspend fun processHit(entity: DataEntity): Boolean
├─> Decode event from disk
├─> Accumulate in memory (if not already present)
└─> return true → clear from disk (event now in memory)
Copied to your clipboard
func processHit(entity: DataEntity, completion: (Bool) -> Void)
├─> Decode event from disk
├─> Accumulate in memory (if not already present)
└─> completion(true) → clear from disk (event now in memory)
Copied to your clipboard
private fun buildAssetMetricsCollection(events: List<Event>): AssetMetricsCollection {
val groupedEvents = events.groupBy { it.assetKey ?: "" }
val metricsMap = mutableMapOf<String, AssetMetrics>()
for ((key, events) in groupedEvents) {
val views = events.count { it.interactionType == InteractionType.VIEW }
val clicks = events.count { it.interactionType == InteractionType.CLICK }
metricsMap[key] = AssetMetrics(viewCount = views, clickCount = clicks, ...)
}
return AssetMetricsCollection(metricsMap)
}
Copied to your clipboard
func buildAssetMetricsCollection(from events: [Event]) -> AssetMetricsCollection {
let groupedEvents = Dictionary(grouping: events) { $0.assetKey ?? "" }
var metricsMap: [String: AssetMetrics] = [:]
for (key, events) in groupedEvents {
let views = events.filter { $0.interactionType == .view }.count
let clicks = events.filter { $0.interactionType == .click }.count
metricsMap[key] = AssetMetrics(viewCount: views, clickCount: clicks, ...)
}
return AssetMetricsCollection(metrics: metricsMap)
}
Copied to your clipboard
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
private val stateMutex = kotlinx.coroutines.sync.Mutex()
private val mutex = Mutex()