DurableStateStorePostgreSQL

peloton.persistence.postgresql.DurableStateStorePostgreSQL
class DurableStateStorePostgreSQL(using xa: Transactor[IO]) extends DurableStateStore

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def clear(): IO[Unit]

Clears/resets the internal data structures used by the storage backend if not already created.

Clears/resets the internal data structures used by the storage backend if not already created.

Attributes

Returns

an IO[Unit]

Definition Classes
override def create(): IO[Unit]

Create and initialize the internal data structures used by the storage backend if not already created.

Create and initialize the internal data structures used by the storage backend if not already created.

Note: It is guaranteed that this operation will not truncate/clear the underlying storage, but just create it in case it does not already exist. If you need to clear the storage, use method clear instead.

Attributes

Returns

an IO[Unit]

Definition Classes
override def drop(): IO[Unit]

Drops the internal data structures used by the storage backend.

Drops the internal data structures used by the storage backend.

Attributes

Returns

an IO[Unit]

Definition Classes
override def readEncodedState(persistenceId: PersistenceId): IO[Option[EncodedState]]

Reads the current encoded (serialized) state for a given persistenceId from the storage backend.

Reads the current encoded (serialized) state for a given persistenceId from the storage backend.

Value parameters

persistenceId

The PersistenceId of the encoded state instance to read

Attributes

Returns

Some if the entry exists in the storage backend, else None

Definition Classes
override def writeEncodedState(persistenceId: PersistenceId, state: EncodedState): IO[Unit]

Writes (creates or replaces) an encoded (serialized) state for a given persistenceId into the storage backend.

Writes (creates or replaces) an encoded (serialized) state for a given persistenceId into the storage backend.

The method will fail if the revision of new encoded state is not exactly the successor of the revision of the current encoded state, i.e., newRevision == currentRevision + 1. This ensures that there is no collision with persistence IDs that have accidentally been used multiple times.

Implementation note: The revision check could have easily been put into the generic write method. This would have eliminated the need to do the logic in each implementation of writeEncodedState, but it would also have eliminated the possibility to do the logic more efficient. This is why the decision was made to do it here for each implementation.

Value parameters

encodedState

The state instance of type EncodedState

persistenceId

The PersistenceId of the encoded state instance to write

Attributes

Returns

IO[Unit]

Definition Classes

Inherited methods

def read[A](persistenceId: PersistenceId)(using payloadCodec: PayloadCodec[A]): IO[Option[DurableState[A]]]

Reads the current revision of the DurableState for type A from storage backend.

Reads the current revision of the DurableState for type A from storage backend.

Value parameters

payloadCodec

a given PayloadCodec to convert instances of type A to a byte array and vice versa

persistenceId

The PersistenceId of the durable state instance to read

Attributes

Returns

Some if the entry exists in the storage backend, else None

Inherited from:
DurableStateStore
def write[A](persistenceId: PersistenceId, state: DurableState[A])(using payloadCodec: PayloadCodec[A]): IO[Unit]

Writes a new revision of the DurableState for type A from storage backend.

Writes a new revision of the DurableState for type A from storage backend.

The method will fail if the revision of new encoded state is not exactly the successor of the revision of the current encoded state, i.e., newRevision == currentRevision + 1. This ensures that there is no collision with persistence IDs that have accidentally been used multiple times.

Value parameters

payloadCodec

a given PayloadCodec to convert instances of type A to a byte array and vice versa

persistenceId

The PersistenceId of the durable state instance to write

state

The DurableState of type A

Attributes

Returns

An IO[Unit]

Inherited from:
DurableStateStore