Client calls and routing
ITroolioClient is the application-facing client contract for addressing actors and fetching read models. Tell<TActor> sends a typed actor message to an actor ID. Ask<TActor,TResult> sends a typed message and awaits a result. Get<TReadModel> resolves a read model by ID. The interface does not authenticate or authorize a business command for you; enforce those rules before calling it.
On this page
Register the client
TroolioClientExtensions.AddTroolioClient registers a singleton client using the application name and actor assemblies. The current implementation reads appsettings.json, optional environment-specific JSON files, and environment variables. With <appName>:Clustering:Storage set to Local, it uses demo clustering. Otherwise it configures an Azure Storage gateway from <appName>:Clustering:ConnectionString. Review that choice for the deployment and keep its credential out of source control.
The client constructor starts Orleans hosted services and connects to the cluster. Treat client creation as an application startup step, account for connection failures, and verify shutdown behavior in your host. IActorSystemExtensions.ActorOf<TActor>(id) and Worker<TActor>() offer typed actor references inside code that already has an actor system.
Delivery semantics
A successful Tell indicates that the client call completed, not that a selected atomic transaction and every downstream projection completed. For commands requiring an authoritative outcome, use a response or operation receipt and the appropriate selected route. Queries can observe a current actor state while read models lag behind the event commit.
Example: Tell an actor and read a view
The client addresses a typed actor by ID. A read model query uses its own ID and may observe a later projection state.
public static Task Send(ITroolioClient client, Metadata headers) =>
client.Tell<ICounterActor>("42", new Increment(headers));
public static async Task<int> ReadProjection(ITroolioClient client) =>
(await client.Get<CounterReadModel>("d1cb4bc0-114d-4a8c-9a5e-f460784d7340")).Count;