Skip to content

PersistenceStrategy

Xavier F. Gouchet edited this page Sep 4, 2024 · 1 revision

interface PersistenceStrategy

The main strategy used to persist data between the moment it's tracked and created, and the moment it's uploaded to the intake.

Types

PersistenceStrategy.Batch

PersistenceStrategy.Factory

Functions

currentMetadata

@WorkerThread

abstract fun currentMetadata(): ByteArray?

Return

the metadata of the current writeable batch

dropAll

@WorkerThread

abstract fun dropAll()

Drop all data.

lockAndReadNext

@WorkerThread

abstract fun lockAndReadNext(): PersistenceStrategy.Batch?

Reads the next batch of data and lock it so that it can't be read or written to by anyone.

migrateData

abstract fun migrateData(targetStrategy: PersistenceStrategy)

Migrate the data to a different PersistenceStrategy. All readable and ongoing batches must be transferred to the given strategy.

unlockAndDelete

@WorkerThread

abstract fun unlockAndDelete(batchId: String)

Marks the batch as unlocked and to be deleted. The corresponding batch should not be returned in any call to lockAndReadNext.

unlockAndKeep

@WorkerThread

abstract fun unlockAndKeep(batchId: String)

Marks the batch as unlocked and to be kept to be read again later.

write

@WorkerThread

abstract fun write(event: RawBatchEvent, batchMetadata: ByteArray?, eventType: EventType): Boolean

Writes the content of the event to the current available batch.

Return

true if event was written, false otherwise.

Parameters
event the event to write (content + metadata)
batchMetadata the optional updated batch metadata
eventType additional information about the event that can impact the way it is stored. Note: events with the CRASH type are being sent as part of the Crash Reporting feature, and implies that the process will exit soon, meaning that those event must be kept synchronously and in a way to be retrieved after the app restarts in a new process (e.g.: on the file system, or in a local database).
Clone this wiki locally