readSuspend

abstract suspend fun <T> readSuspend(context: C, readFunction: suspend Reader<C, D>.() -> T): T

Read stuff

The function will suspend until a read lock has been acquired. No event will be processed while the readFunction is executed.

This function differs from the normal read function in that the readFunction can suspend, e.g. it is possible to do network calls within the readFunction. This may cause performance issues for the rest of the system, so it should be used with care. Also, don't try to submit an event while in the readFunction as this will cause a deadlock bringing the application to a halt. If possible, use the normal read function instead of this.

Return

whatever the readFunction returns

Parameters

context

including the actorIdentity on whose behalf the read happens. This actor can be overridden inside readFunction (see Reader).

readFunction

a function literal with a Reader receiver

Throws

if the actor tries to read a model it is not authorized to access