This is a test project using Microsoft Orleans, Asp.NET Core and the Orleans' Direct Client functionality that "allows co-hosting a client and silo in a way that let the client communicate more efficiently with not just the silo it's attached to, but the entire cluster." To give a complete overview it implements:
- a WebApi controller,
- DI example, injecting a custom Transient service in the controller,
- grain storage using Azure Blob and Azure Table,
- ProtobufNet serialization and a custom serialization for DateTimeOffset
Co-hosting cluster and http client can be achieved using the Hosted client. This means that a Orleans Silo and a Http API may be the same process, so no serialization would be done in that case. Direct client is enabled by default from Orleans 2.3. The documentation is coming, take a look at the github issue here. In the meantime take a look to this stackoverflow thread.
Install Asp Net Core 2.2 SDK (> 2.2.301) Install Azure Storage Emulator (optional) Install Azure Storage Explorer (> 1.6.2)
- Install dotnet core 2.2 (or higher).
- Run the Azure Storage Emulator
- Run the WebApi: in src/06-Frontends/WebApi > run
dotnet run
- Navigate to http://localhost:5000/api/v1/products to hit the WebApi GET endpoint
- Navigate to http://localhost:8080/ for the Orleans Dashboard
- (optional) Run the test client: in src/06-Frontends/TestClient > run
dotnet run
This code should be considered experimental. It works, however the project may have rough edges and has not been thoroughly tested. I welcome feedback!
-- Mauro