-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add extra environment to onMessage (#71)
* Implement support for adding extra environment to onMessage * Update README * Add timeout for Sharding tests Co-authored-by: Pierre Ricadat <[email protected]>
- Loading branch information
1 parent
5847b5d
commit 7dda318
Showing
5 changed files
with
85 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package zio.akka.cluster | ||
|
||
import zio.{ Has, Ref, Tagged, Task, UIO, ZIO } | ||
|
||
import scala.concurrent.duration.Duration | ||
|
||
package object sharding { | ||
type Entity[State] = Has[Entity.Service[State]] | ||
|
||
object Entity { | ||
|
||
trait Service[State] { | ||
def replyToSender[R](msg: R): Task[Unit] | ||
def id: String | ||
def state: Ref[Option[State]] | ||
def stop: UIO[Unit] | ||
def passivate: UIO[Unit] | ||
def passivateAfter(duration: Duration): UIO[Unit] | ||
} | ||
|
||
def replyToSender[State: Tagged, R](msg: R) = | ||
ZIO.accessM[Entity[State]](_.get.replyToSender(msg)) | ||
def id[State: Tagged] = | ||
ZIO.access[Entity[State]](_.get.id) | ||
def state[State: Tagged] = | ||
ZIO.access[Entity[State]](_.get.state) | ||
def stop[State: Tagged] = | ||
ZIO.accessM[Entity[State]](_.get.stop) | ||
def passivate[State: Tagged] = | ||
ZIO.accessM[Entity[State]](_.get.passivate) | ||
def passivateAfter[State: Tagged](duration: Duration) = | ||
ZIO.accessM[Entity[State]](_.get.passivateAfter(duration)) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters