Subscribing to Azure Event Hubs events
The Codebreaker.Live
project previously offered a gRPC service that was invoked by the game APIs service to publish completed games via SignalR. Instead of offering a gRPC service, we can subscribe to events.
Create a new Codebreaker.Ranking
project so that you can offer minimal APIs. This project will receive the same events as Codebreaker.Live
but write them to a database to offer ranks for games based on days, weeks, and months.
To create the Codebreaker.Ranking
project, use the following command:
dotnet new webapi -minimal -o Codebreaker.Ranking
Add the newly created project as a reference to Codebreaker.AppHost
, and reference Codebreaker.ServiceDefaults
to configure the service defaults. Now, we can update app model.
Defining app-model for Event Hubs subscribers
With the AppHost project, the live and ranks projects reference the event hub, similar to the events publishing project:
Codebreaker.AppHost/Program.cs
var...