Skip to content

Commit

Permalink
feat: refactor some naming to clarify
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina committed Nov 1, 2024
1 parent a1b356d commit 5268708
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ internal enum class SyncType {
* @param syncId the unique identifier for the sync process.
* @param syncStartedMoment the moment when the sync process started.
*/
internal fun KaliumLogger.provideNewSyncManagerStartedLogger(
internal fun KaliumLogger.provideNewSyncManagerLogger(
syncType: SyncType,
syncId: String = uuid4().toString(),
syncStartedMoment: Instant = Clock.System.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import com.wire.kalium.logic.data.sync.SlowSyncStatus
import com.wire.kalium.logic.kaliumLogger
import com.wire.kalium.logic.sync.SyncExceptionHandler
import com.wire.kalium.logic.sync.SyncType
import com.wire.kalium.logic.sync.provideNewSyncManagerStartedLogger
import com.wire.kalium.logic.sync.provideNewSyncManagerLogger
import com.wire.kalium.logic.sync.slow.SlowSyncManager
import com.wire.kalium.logic.util.ExponentialDurationHelper
import com.wire.kalium.logic.util.ExponentialDurationHelperImpl
Expand All @@ -53,7 +53,6 @@ import kotlinx.coroutines.flow.runningFold
import kotlinx.coroutines.launch
import kotlinx.coroutines.selects.select
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
Expand Down Expand Up @@ -188,16 +187,16 @@ internal class IncrementalSyncManager(
incrementalSyncWorker
.processEventsWhilePolicyAllowsFlow()
.cancellable()
.runningFold(uuid4().toString() to Clock.System.now()) { syncData: Pair<String, Instant>, eventSource ->
val syncLogger = kaliumLogger.provideNewSyncManagerStartedLogger(SyncType.INCREMENTAL, syncData.first)
.runningFold(uuid4().toString() to Clock.System.now()) { syncData, eventSource ->
val syncLogger = kaliumLogger.provideNewSyncManagerLogger(SyncType.INCREMENTAL, syncData.first)
val newState = when (eventSource) {
EventSource.PENDING -> {
syncLogger.logSyncStarted()
IncrementalSyncStatus.FetchingPendingEvents
}

EventSource.LIVE -> {
syncLogger.logSyncCompleted(Clock.System.now() - syncData.second)
syncLogger.logSyncCompleted(duration = Clock.System.now() - syncData.second)
exponentialDurationHelper.reset()
IncrementalSyncStatus.Live
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.wire.kalium.logic.kaliumLogger
import com.wire.kalium.logic.sync.SyncExceptionHandler
import com.wire.kalium.logic.sync.SyncType
import com.wire.kalium.logic.sync.incremental.IncrementalSyncManager
import com.wire.kalium.logic.sync.provideNewSyncManagerStartedLogger
import com.wire.kalium.logic.sync.provideNewSyncManagerLogger
import com.wire.kalium.logic.sync.slow.migration.SyncMigrationStepsProvider
import com.wire.kalium.logic.sync.slow.migration.steps.SyncMigrationStep
import com.wire.kalium.logic.util.ExponentialDurationHelper
Expand Down Expand Up @@ -189,7 +189,7 @@ internal class SlowSyncManager(
}

private suspend fun performSlowSync(migrationSteps: List<SyncMigrationStep>) {
val syncLogger = kaliumLogger.provideNewSyncManagerStartedLogger(SyncType.SLOW)
val syncLogger = kaliumLogger.provideNewSyncManagerLogger(SyncType.SLOW)
syncLogger.logSyncStarted()
logger.i("Starting SlowSync as all criteria are met and it wasn't performed recently")
slowSyncWorker.slowSyncStepsFlow(migrationSteps).cancellable().collect { step ->
Expand Down

0 comments on commit 5268708

Please sign in to comment.