Class PersistableActor<TLogic, TActor>

A class that extends the functionality of a standard actor with persistence and locking capabilities. It integrates with a storage manager that supports lock-enabled storage, allowing for controlled read/write access to the actor's state.

The class offers methods to initialize, save, and close the actor, managing its lifecycle and ensuring data integrity through optional locking during state persistence.

Use withPersistableActor to use this.

Type Parameters

  • TLogic extends AnyActorLogic

  • TActor extends Actor<TLogic>

Constructors

Properties

Accessors

Methods

Constructors

Properties

_actor: undefined | TActor
initiated: Boolean = false
params: PersistableActorInput<TLogic, TActor> & {
    persistancePath: string;
}

Type declaration

  • persistancePath: string

Accessors

  • get actor(): TActor
  • Provides access to the underlying actor instance, ensuring it has been properly initialized.

    Returns TActor

    Throws

    Throws an error if the actor has not been initialized yet.

Methods

  • Cleans up resources associated with the actor and releases any locks if they were acquired.

    This method should be called to ensure graceful shutdown of the actor.

    Returns Promise<void>

  • Initializes the actor by loading its state from the storage and setting it up with the provided actor creator.

    Parameters

    • checkForAlreadyInitiated: boolean = true

      A flag to prevent re-initialization if the actor has already been initiated.

    Returns Promise<void>

    Throws

    Throws an error if the actor is already initiated and re-initialization is attempted.

  • Persists the current state of the actor to the storage.

    The method ensures data integrity by optionally acquiring a lock before writing the actor's state.

    Returns Promise<void>

Generated using TypeDoc