akka.cluster.ddata.typed.scaladsl
ReplicatorMessageAdapter
Companion object ReplicatorMessageAdapter
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 scala.concurrent.Future 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
- Protected
Instance Constructors
- new ReplicatorMessageAdapter(context: ActorContext[A], replicator: ActorRef[Command], unexpectedAskTimeout: FiniteDuration)
- context
The ActorContext of the requesting actor. The
ReplicatorMessageAdaptercan only be used in this actor.- replicator
The replicator to interact with, typically
DistributedData(system).replicator.- unexpectedAskTimeout
The timeout to use for
askoperations. This should be longer than thetimeoutgiven in Replicator.WriteConsistency and Replicator.ReadConsistency. The replicator will always send a reply within those timeouts so theunexpectedAskTimeoutshould not occur, but for cleanup in a failure situation it must still exist. IfaskUpdate,askGetoraskDeletetakes longer then thisunexpectedAskTimeouta 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] toany2stringadd[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] toArrowAssoc[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: (ActorRef[DeleteResponse[B]]) => Delete[B], responseAdapter: (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
responseAdapterfunction.Note that
createRequestis a function that creates theDeletemessage from the providedActorRef[DeleteResponse]that the the replicator will send the response message back through. Use thatActorRef[DeleteResponse]as thereplyToparameter in theDeletemessage. - def askGet(createRequest: (ActorRef[GetResponse[B]]) => Get[B], responseAdapter: (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
responseAdapterfunction.Note that
createRequestis a function that creates theGetmessage from the providedActorRef[GetResponse]that the the replicator will send the response message back through. Use thatActorRef[GetResponse]as thereplyToparameter in theGetmessage. - def askReplicaCount(createRequest: (ActorRef[ReplicaCount]) => GetReplicaCount, responseAdapter: (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
responseAdapterfunction.Note that
createRequestis a function that creates theGetReplicaCountmessage from the providedActorRef[ReplicaCount]that the the replicator will send the response message back through. Use thatActorRef[ReplicaCount]as thereplyToparameter in theGetReplicaCountmessage. - def askUpdate(createRequest: (ActorRef[UpdateResponse[B]]) => Update[B], responseAdapter: (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
responseAdapterfunction.Note that
createRequestis a function that creates theUpdatemessage from the providedActorRef[UpdateResponse]that the the replicator will send the response message back through. Use thatActorRef[UpdateResponse]as thereplyToparameter in theUpdatemessage. - def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- 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] toEnsuring[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] toEnsuring[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] toEnsuring[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] toEnsuring[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: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- 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
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def subscribe(key: Key[B], responseAdapter: (SubscribeResponse[B]) => A): Unit
Subscribe to changes of the given
key.Subscribe to changes of the given
key. The Replicator.Changed, Replicator.Deleted and Replicator.Expired messages from the replicator are transformed to the message protocol of the requesting actor with the givenresponseAdapterfunction. - 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(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from ReplicatorMessageAdapter[A, B] toStringFormat[ReplicatorMessageAdapter[A, B]] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.12.16) Use
formatString.format(value)instead ofvalue.formatted(formatString), or use thef""string interpolator. In Java 15 and later,formattedresolves to the new method in String which has reversed parameters.
- def →[B](y: B): (ReplicatorMessageAdapter[A, B], B)
- Implicit
- This member is added by an implicit conversion from ReplicatorMessageAdapter[A, B] toArrowAssoc[ReplicatorMessageAdapter[A, B]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.