Skip to content

Commit 1dbe0dd

Browse files
Adding a method to get the pod address for an entity. (#164)
1 parent 9b2d151 commit 1dbe0dd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

entities/src/main/scala/com/devsisters/shardcake/Sharding.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,15 @@ class Sharding private (
120120
stopSingletonsIfNeeded *>
121121
ZIO.logDebug(s"Unassigned shards: ${renderShardIds(shards)}")
122122

123-
private[shardcake] def isEntityOnLocalShards(recipientType: RecipientType[_], entityId: String): UIO[Boolean] =
123+
def getPodAddress(recipientType: RecipientType[_], entityId: String): UIO[Option[PodAddress]] =
124124
for {
125125
shards <- shardAssignments.get
126126
shardId = getShardId(recipientType, entityId)
127127
pod = shards.get(shardId)
128-
} yield pod.contains(address)
128+
} yield pod
129+
130+
def isEntityOnLocalShards(recipientType: RecipientType[_], entityId: String): UIO[Boolean] =
131+
getPodAddress(recipientType, entityId).map(pod => pod.contains(address))
129132

130133
val getAssignments: UIO[Map[ShardId, PodAddress]] =
131134
shardAssignments.get

0 commit comments

Comments
 (0)