class ReplicatorMessageAdapter[A, B <: ReplicatedData] extends AnyRef
When interacting with the Replicator
from an actor this class provides convenient
methods that adapts the response messages to the requesting actor's message protocol.
One ReplicatorMessageAdapter
instance can be used for a given ReplicatedData
type,
e.g. an OrSet<String>
. Interaction with several Keys can be used via the same adapter
but they must all be of the same ReplicatedData
type. For interaction with several different
ReplicatedData
types, e.g. an OrSet<String>
and a GCounter
, an adapter can be created
for each type.
For the default replicator in the DistributedData extension a ReplicatorMessageAdapter
can be created with DistributedData.withReplicatorMessageAdapter.
*Warning*: ReplicatorMessageAdapter
is not thread-safe and must only be used from the actor
corresponding to the given ActorContext
. It must not be accessed from threads other
than the ordinary actor message processing thread, such as java.util.concurrent.CompletionStage
callbacks. It must not be shared between several actor instances.
- A
Message type of the requesting actor.
- B
Type of the ReplicatedData.
- Alphabetic
- By Inheritance
- ReplicatorMessageAdapter
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
ReplicatorMessageAdapter(context: ActorContext[A], replicator: ActorRef[Command], unexpectedAskTimeout: Duration)
- context
The ActorContext of the requesting actor. The
ReplicatorMessageAdapter
can only be used in this actor.- replicator
The replicator to interact with, typically
DistributedData.get(system).replicator
.- unexpectedAskTimeout
The timeout to use for
ask
operations. This should be longer than thetimeout
given in Replicator.WriteConsistency and Replicator.ReadConsistency. The replicator will always send a reply within those timeouts so theunexpectedAskTimeout
should not occur, but for cleanup in a failure situation it must still exist. IfaskUpdate
,askGet
oraskDelete
takes longer then thisunexpectedAskTimeout
a java.util.concurrent.TimeoutException will be thrown by the requesting actor and may be handled by supervision.
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from ReplicatorMessageAdapter[A, B] to any2stringadd[ReplicatorMessageAdapter[A, B]] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
->[B](y: B): (ReplicatorMessageAdapter[A, B], B)
- Implicit
- This member is added by an implicit conversion from ReplicatorMessageAdapter[A, B] to ArrowAssoc[ReplicatorMessageAdapter[A, B]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
askDelete(createRequest: Function[ActorRef[DeleteResponse[B]], Delete[B]], responseAdapter: Function[DeleteResponse[B], A]): Unit
Send a Replicator.Delete request to the replicator.
Send a Replicator.Delete request to the replicator. The Replicator.DeleteResponse message is transformed to the message protocol of the requesting actor with the given
responseAdapter
function.Note that
createRequest
is a function that creates theDelete
message from the providedActorRef[DeleteResponse]
that the the replicator will send the response message back through. Use thatActorRef[DeleteResponse]
as thereplyTo
parameter in theDelete
message. -
def
askGet(createRequest: Function[ActorRef[GetResponse[B]], Get[B]], responseAdapter: Function[GetResponse[B], A]): Unit
Send a Replicator.Get request to the replicator.
Send a Replicator.Get request to the replicator. The Replicator.GetResponse message is transformed to the message protocol of the requesting actor with the given
responseAdapter
function.Note that
createRequest
is a function that creates theGet
message from the providedActorRef[GetResponse]
that the the replicator will send the response message back through. Use thatActorRef[GetResponse]
as thereplyTo
parameter in theGet
message.- Annotations
- @silent()
-
def
askReplicaCount(createRequest: Function[ActorRef[ReplicaCount], GetReplicaCount], responseAdapter: Function[ReplicaCount, A]): Unit
Send a Replicator.GetReplicaCount request to the replicator.
Send a Replicator.GetReplicaCount request to the replicator. The Replicator.ReplicaCount message is transformed to the message protocol of the requesting actor with the given
responseAdapter
function.Note that
createRequest
is a function that creates theGetReplicaCount
message from the providedActorRef[ReplicaCount]
that the the replicator will send the response message back through. Use thatActorRef[ReplicaCount]
as thereplyTo
parameter in theGetReplicaCount
message. -
def
askUpdate(createRequest: Function[ActorRef[UpdateResponse[B]], Update[B]], responseAdapter: Function[UpdateResponse[B], A]): Unit
Send a Replicator.Update request to the replicator.
Send a Replicator.Update request to the replicator. The Replicator.UpdateResponse message is transformed to the message protocol of the requesting actor with the given
responseAdapter
function.Note that
createRequest
is a function that creates theUpdate
message from the providedActorRef[UpdateResponse]
that the the replicator will send the response message back through. Use thatActorRef[UpdateResponse]
as thereplyTo
parameter in theUpdate
message. -
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
def
ensuring(cond: (ReplicatorMessageAdapter[A, B]) ⇒ Boolean, msg: ⇒ Any): ReplicatorMessageAdapter[A, B]
- Implicit
- This member is added by an implicit conversion from ReplicatorMessageAdapter[A, B] to Ensuring[ReplicatorMessageAdapter[A, B]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (ReplicatorMessageAdapter[A, B]) ⇒ Boolean): ReplicatorMessageAdapter[A, B]
- Implicit
- This member is added by an implicit conversion from ReplicatorMessageAdapter[A, B] to Ensuring[ReplicatorMessageAdapter[A, B]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): ReplicatorMessageAdapter[A, B]
- Implicit
- This member is added by an implicit conversion from ReplicatorMessageAdapter[A, B] to Ensuring[ReplicatorMessageAdapter[A, B]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): ReplicatorMessageAdapter[A, B]
- Implicit
- This member is added by an implicit conversion from ReplicatorMessageAdapter[A, B] to Ensuring[ReplicatorMessageAdapter[A, B]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from ReplicatorMessageAdapter[A, B] to StringFormat[ReplicatorMessageAdapter[A, B]] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
subscribe(key: Key[B], responseAdapter: Function[SubscribeResponse[B], A]): Unit
Subscribe to changes of the given
key
.Subscribe to changes of the given
key
. The Replicator.Changed and Replicator.Deleted messages from the replicator are transformed to the message protocol of the requesting actor with the givenresponseAdapter
function. -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
unsubscribe(key: Key[B]): Unit
Unsubscribe from a previous subscription of a given
key
.Unsubscribe from a previous subscription of a given
key
. -
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
→[B](y: B): (ReplicatorMessageAdapter[A, B], B)
- Implicit
- This member is added by an implicit conversion from ReplicatorMessageAdapter[A, B] to ArrowAssoc[ReplicatorMessageAdapter[A, B]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc