# SPDX-License-Identifier: Apache-2.0

pekko.actor {

  serialization-identifiers."org.apache.pekko.persistence.typed.serialization.ReplicatedEventSourcingSerializer" = 40

  serializers.replicated-event-sourcing = "org.apache.pekko.persistence.typed.serialization.ReplicatedEventSourcingSerializer"

  serialization-bindings {
    "org.apache.pekko.persistence.typed.internal.VersionVector" = replicated-event-sourcing
    "org.apache.pekko.persistence.typed.crdt.Counter" = replicated-event-sourcing
    "org.apache.pekko.persistence.typed.crdt.Counter$Updated" = replicated-event-sourcing
    "org.apache.pekko.persistence.typed.crdt.ORSet" = replicated-event-sourcing
    "org.apache.pekko.persistence.typed.crdt.ORSet$DeltaOp" = replicated-event-sourcing
    "org.apache.pekko.persistence.typed.internal.ReplicatedEventMetadata" = replicated-event-sourcing
    "org.apache.pekko.persistence.typed.internal.ReplicatedSnapshotMetadata" = replicated-event-sourcing
    "org.apache.pekko.persistence.typed.internal.PublishedEventImpl" = replicated-event-sourcing
  }
}

pekko.persistence.typed {

  # Persistent actors stash while recovering or persisting events,
  # this setting configures the default capacity of this stash.
  #
  # Stashing is always bounded to the size that is defined in this setting.
  # You can set it to large values, however "unbounded" buffering is not supported.
  # Negative or 0 values are not allowed.
  stash-capacity = 4096

  # Configure how to react when the event sourced stash overflows. This can happen in two scenarios:
  # when a event sourced actor is doing recovery, persisting or snapshotting and it gets more than
  # 'stash-capacity' commands, or if more than 'stash-capacity' commands are manually stashed with the
  # 'stash' effect.
  #
  # Possible options
  # - drop - the message is published as a org.apache.pekko.actor.typed.Dropped message on the event bus
  # - fail - an exception is thrown so that the actor is failed
  stash-overflow-strategy = "drop"

  # enables automatic DEBUG level logging of messages stashed automatically by an EventSourcedBehavior,
  # this may happen while it receives commands while it is recovering events or while it is persisting events
  log-stashing = off

  # By default, internal event sourced behavior logging are sent to
  # org.apache.pekko.persistence.typed.internal.EventSourcedBehaviorImpl
  # this can be changed by setting this to 'true' in which case the internal logging is sent to
  # the actor context logger.
  use-context-logger-for-internal-logging = false

  # Commands get stashed during persistence and un-stashed afterward. Normally, when many read-only
  # (i.e. that do not cause any persistence) commands are present in the stash, the functions are called
  # in a loop to unstash all of them. Setting this to true, will cause functions to be called
  # recursively (that was the default before this setting was introduced). That might cause a stack
  # overflow in case there are many messages to unstash.
  recurse-when-unstashing-read-only-commands = false
}

pekko.reliable-delivery {
  producer-controller {
    event-sourced-durable-queue {
      # Max duration for the exponential backoff for persist failures.
      restart-max-backoff = 10s

      # Snapshot after this number of events. See RetentionCriteria.
      snapshot-every = 1000

      # Number of snapshots to keep. See RetentionCriteria.
      keep-n-snapshots = 2

      # Delete events after snapshotting. See RetentionCriteria.
      delete-events = on

      # Cleanup entries that haven't be used for this duration.
      cleanup-unused-after = 3600s

      # The journal plugin to use, by default it will use the plugin configured by
      # `pekko.persistence.journal.plugin`.
      journal-plugin-id = ""

      # The journal plugin to use, by default it will use the plugin configured by
      # `pekko.persistence.snapshot-store.plugin`.
      snapshot-plugin-id = ""
    }
  }
}
