package com.aramark.ess.configuration import com.aramark.ess.command.domain.aggregates.SyncHost import com.aramark.ess.command.domain.aggregates.SyncHostCommandHandler import org.axonframework.eventhandling.EventBus import org.axonframework.eventsourcing.EventCountSnapshotTriggerDefinition import org.axonframework.eventsourcing.Snapshotter import org.axonframework.spring.config.AxonConfiguration import org.springframework.beans.factory.annotation.Value import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @Configuration internal class SyncHostConfiguration { @Bean fun syncHostCommandHandler(axonConfiguration: AxonConfiguration, eventBus: EventBus) = SyncHostCommandHandler(axonConfiguration.repository(SyncHost::class.java), eventBus) @Value("\${axon.snapshot.trigger.treshold.synchost}") private val snapshotTriggerTresholdSyncHost: Int = 100 @Value("\${axon.snapshot.trigger.treshold.syncpoint}") private val snapshotTriggerTresholdSyncPoint: Int = 100 @Bean("syncHostSnapshotTriggerDefinition") fun syncHostSnapshotTriggerDefinition(snapshotter: Snapshotter) = EventCountSnapshotTriggerDefinition(snapshotter, snapshotTriggerTresholdSyncHost) @Bean("courierOrderSnapshotTriggerDefinition") fun syncPointSnapshotTriggerDefinition(snapshotter: Snapshotter) = EventCountSnapshotTriggerDefinition(snapshotter, snapshotTriggerTresholdSyncPoint) }