final class Cleanup extends AnyRef
Tool for deleting all events and/or snapshots for a given list of persistenceIds
without using persistent actors.
It's important that the actors with corresponding persistenceId
are not running
at the same time as using the tool.
If neverUsePersistenceIdAgain
is true
then the highest used sequence number is deleted and
the persistenceId
should not be used again, since it would be confusing to reuse the same sequence
numbers for new events.
When a list of persistenceIds
are given they are deleted sequentially in the order
of the list. It's possible to parallelize the deletes by running several cleanup operations
at the same time operating on different sets of persistenceIds
.
- Annotations
- @ApiMayChange()
- Source
- Cleanup.scala
- Alphabetic
- By Inheritance
- Cleanup
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Cleanup(systemProvider: ClassicActorSystemProvider)
- new Cleanup(systemProvider: ClassicActorSystemProvider, settings: CleanupSettings)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def cleanupBeforeSnapshot(persistenceIds: Seq[String], nrSnapshotsToKeep: Int, keepAfter: Long): Future[Done]
Requires Cassandra 3+
Requires Cassandra 3+
See single persistenceId overload for what is done for each persistence id
- def cleanupBeforeSnapshot(persistenceIds: Seq[String], nrSnapshotsToKeep: Int): Future[Done]
Requires Cassandra 3+
Requires Cassandra 3+
See single persistenceId overload for what is done for each persistence id
- def cleanupBeforeSnapshot(persistenceId: String, nrSnapshotsToKeep: Int, keepAfter: Long): Future[Done]
Requires Cassandra 3+
Requires Cassandra 3+
Deletes all events for the given persistence id from before the first after keepAfter. If there are not enough snapshots to satisfy nrSnapshotsToKeep then snapshots before keepAfter will also be kept.
WARNING: deleting events is generally discouraged in event sourced systems. once deleted the event by tag view can not be re-built
- def cleanupBeforeSnapshot(persistenceId: String, nrSnapshotsToKeep: Int): Future[Done]
Requires Cassandra 3+
Requires Cassandra 3+
Deletes all but the last N snapshots and deletes all events before this snapshot Does not delete from the tag_views table
WARNING: deleting events is generally discouraged in event sourced systems. once deleted the event by tag view can not be re-built
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def deleteAll(persistenceId: String, neverUsePersistenceIdAgain: Boolean): Future[Done]
Delete everything related to one single
persistenceId
.Delete everything related to one single
persistenceId
. All events, tagged events, and snapshots are deleted. - def deleteAll(persistenceIds: Seq[String], neverUsePersistenceIdAgain: Boolean): Future[Done]
Delete everything related to the given list of
persistenceIds
.Delete everything related to the given list of
persistenceIds
. All events, tagged events, and snapshots are deleted. - def deleteAllEvents(persistenceId: String, neverUsePersistenceIdAgain: Boolean): Future[Done]
Delete all events related to one single
persistenceId
.Delete all events related to one single
persistenceId
. Snapshots are not deleted. - def deleteAllEvents(persistenceIds: Seq[String], neverUsePersistenceIdAgain: Boolean): Future[Done]
Delete all events related to the given list of
persistenceIds
.Delete all events related to the given list of
persistenceIds
. Snapshots are not deleted. - def deleteAllSnapshots(persistenceId: String): Future[Done]
Delete all snapshots related to one single
persistenceId
.Delete all snapshots related to one single
persistenceId
. Events are not deleted. - def deleteAllSnapshots(persistenceIds: Seq[String]): Future[Done]
Delete all snapshots related to the given list of
persistenceIds
.Delete all snapshots related to the given list of
persistenceIds
. Events are not deleted. - def deleteAllTaggedEvents(persistenceId: String): Future[Done]
Delete all events from
tag_views
table related to to one singlepersistenceId
.Delete all events from
tag_views
table related to to one singlepersistenceId
. Events inmessages
(journal) table are not deleted and snapshots are not deleted. - def deleteAllTaggedEvents(persistenceIds: Seq[String]): Future[Done]
Delete all events from
tag_views
table related to the given list ofpersistenceIds
.Delete all events from
tag_views
table related to the given list ofpersistenceIds
. Events inmessages
(journal) table are not deleted and snapshots are not deleted. - def deleteBeforeSnapshot(persistenceId: String, maxSnapshotsToKeep: Int): Future[Option[SnapshotMetadata]]
Requires Cassandra 3+
Requires Cassandra 3+
Keep N snapshots and delete all older snapshots along.
This operation is much cheaper than including the timestamp because it can use the primary key and limit.
- returns
the snapshot meta of the oldest remaining snapshot. None if there are no snapshots. This can be used to delete events from before the snapshot.
- def deleteBeforeSnapshot(persistenceId: String, snapshotsToKeep: Int, keepAfterUnixTimestamp: Long): Future[Option[SnapshotMetadata]]
Requires Cassandra 3+
Requires Cassandra 3+
Keep all snapshots that occurred after
keepAfter
. If fewer thansnapshotsToKeep
occurred afterkeepAfter
at least that many are kept. Setting this to 1 ensures that at least snapshot is kept even if it is older than thekeepAfter
If only N number of snapshot should be kept prefer overload without timestamp as it is more efficient.
The returned snapshot metadata can be used to issue deletes for events older than the oldest snapshot.
- returns
the snapshot meta of the oldest remaining snapshot. None if there are no snapshots
- def deleteEventsTo(persistenceId: String, toSequenceNr: Long): Future[Done]
Requires Cassandra 3+
Requires Cassandra 3+
Delete all events before a sequenceNr for the given persistence id.
WARNING: deleting events is generally discouraged in event sourced systems. once deleted the event by tag view can not be re-built
- persistenceId
the persistence id to delete for
- toSequenceNr
sequence nr (inclusive) to delete up to
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()