Actor

peloton.actor.Actor
See theActor companion class
object Actor

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Actor.type

Members list

Type members

Classlikes

final class CanAsk[M, R]

This class is used to establish a connection between a message class and the related response class using the ASK pattern. Actor.ask requires a given instance of CanAsk. This ensures at COMPILE TIME that if Actor.ask is called with a message of M, an instance of R (or a failed/cancelled IO) is guaranteed to be returned.

This class is used to establish a connection between a message class and the related response class using the ASK pattern. Actor.ask requires a given instance of CanAsk. This ensures at COMPILE TIME that if Actor.ask is called with a message of M, an instance of R (or a failed/cancelled IO) is guaranteed to be returned.

Example:

sealed trait Message

case class MyMessage() extends Message
case class MyOtherMessage() extends Message
case class MyResponse()

given CanAsk[MyMessage, MyResponse] = canAsk

...

for
 myActor    <- ...                         // spawn an Actor[Message]
 myResponse <- myActor ? MyMessage()       // this will compile, as there is a given instance of
                                           // CanAsk[MyMessage, MyResponse]. The Compiler will also know
                                           // that myResponse os of type MyResponse, not generic type Response.
 myResponse <- myActor ? MyOtherMessage()  // this will NOT compile, as there is no given instance of
                                           // CanAsk[MyOtherMessage, ?].
 _          <- myActor ! MyOtherMessage()  // this will compile, as TELL does not require any givens
yield ()

Attributes

Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

inline def canAsk[M, R]: CanAsk[M, R]
inline def terminate(actor: Actor[_]): IO[Unit]

Terminate a given Actor

Terminate a given Actor

This function is synchronous and effectful. It is guaranteed that the actor is terminated after evaluating the effect.

Value parameters

actor

The actor to terminate

Attributes

Returns

an effect that, on evaluation, will terminate the given actor and evaluate to Unit

Concrete fields

val DefaultTimeout: FiniteDuration