Skip to content

evolution-gaming/sharding-strategy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Versions

From version 2.0.0 this library is based on cats-effect-3. If you want to use it with cats-effect-2, you need to use version prior to 2.0.0, for example, 1.0.7

Sharding Strategies

Build Status Coverage Status Codacy Badge Version License: MIT

Alternative to akka.cluster.sharding.ShardCoordinator.ShardAllocationStrategy

Api

trait ShardingStrategy[F[_]] {

  def allocate(requester: Region, shard: Shard, current: Allocation): F[Option[Region]]

  def rebalance(current: Allocation, inProgress: Set[Shard]): F[List[Shard]]
}

Syntax

val strategy = LeastShardsStrategy()
  .filterShards(...)
  .filterRegions(...)
  .rebalanceThreshold(10)
  .takeShards(10) 
  .shardRebalanceCooldown(1.minute)
  .logging(...)
  .toAllocationStrategy()

Setup

For cats-effect-3

addSbtPlugin("com.evolution" % "sbt-artifactory-plugin" % "0.0.2")

libraryDependencies += "com.evolutiongaming" %% "sharding-strategy" % "2.0.0"

For cats-effect-2

addSbtPlugin("com.evolution" % "sbt-artifactory-plugin" % "0.0.2")

libraryDependencies += "com.evolutiongaming" %% "sharding-strategy" % "1.0.7"