# SPDX-License-Identifier: Apache-2.0

# //#sharding-ext-config
# //#number-of-shards
pekko.cluster.sharding {
  # Number of shards used by the default HashCodeMessageExtractor
  # when no other message extractor is defined. This value must be
  # the same for all nodes in the cluster and that is verified by
  # configuration check when joining. Changing the value requires
  # stopping all nodes in the cluster.
  number-of-shards = 1000
}
# //#number-of-shards
# //#sharding-ext-config


pekko.cluster.sharded-daemon-process {
  # Settings for the sharded daemon process internal usage of sharding are using the pekko.cluster.sharding defaults.
  # Some of the settings can be overridden specifically for the sharded daemon process here. For example can the
  # `role` setting limit what nodes the daemon processes and the keep alive pingers will run on.
  # Some settings can not be changed (remember-entities and related settings, passivation, number-of-shards),
  # overriding those settings will be ignored.
  sharding = ${pekko.cluster.sharding}

  # Each entity is pinged at this interval from each node in the
  # cluster to trigger a start if it has stopped, for example during
  # rebalancing.
  # Note: How the set of actors is kept alive may change in the future meaning this setting may go away.
  keep-alive-interval = 10s
}

pekko.cluster.configuration-compatibility-check.checkers {
  pekko-cluster-sharding-hash-extractor = "org.apache.pekko.cluster.sharding.typed.internal.JoinConfigCompatCheckerClusterSharding"
}

pekko.actor {
  serializers {
    typed-sharding = "org.apache.pekko.cluster.sharding.typed.internal.ShardingSerializer"
  }
  serialization-identifiers {
    "org.apache.pekko.cluster.sharding.typed.internal.ShardingSerializer" = 25
  }
  serialization-bindings {
    "org.apache.pekko.cluster.sharding.typed.ShardingEnvelope" = typed-sharding
  }
}

pekko.reliable-delivery {
  sharding {
    producer-controller = ${pekko.reliable-delivery.producer-controller}
    producer-controller {
      # Limit of how many messages that can be buffered when there
      # is no demand from the consumer side.
      buffer-size = 1000

      # Ask timeout for sending message to worker until receiving Ack from worker
      internal-ask-timeout = 60s

      # If no messages are sent to an entity within this duration the
      # ProducerController for that entity will be removed.
      cleanup-unused-after = 120s

      # In case ShardingConsumerController is stopped and there are pending
      # unconfirmed messages the ShardingConsumerController has to "wake up"
      # the consumer again by resending the first unconfirmed message.
      resend-first-unconfirmed-idle-timeout = 10s

      # Chunked messages not implemented for sharding yet. Override to not
      # propagate property from pekko.reliable-delivery.producer-controller.
      chunk-large-messages = off
    }

    consumer-controller = ${pekko.reliable-delivery.consumer-controller}
    consumer-controller {
      # Limit of how many messages that can be buffered before the
      # ShardingConsumerController is initialized by the Start message.
      buffer-size = 1000
    }
  }
}
