-
Notifications
You must be signed in to change notification settings - Fork 1
1. Installation
First install the Microwave nuget package:
dotnet add package Microwave
Then install the nuget package to choose which persistence you want to use. Right now only mongodb and in memory is supported.
dotnet add package Microwave.Persistence.MongoDb
// or
dotnet add package Microwave.Persistence.InMemory
To register all Microwave dependencies use this in the startup:
using Microwave;
using Microwave.Persistence.MongoDb;
public void ConfigureServices(IServiceCollection services)
{
...
services.AddMicrowave(config =>
{
config.ServiceLocations.Add(new Uri("http://localhost:5000")); // this is me
config.ServiceLocations.Add(new Uri("http://localhost:5002")); // this is another service
});
services.AddMicrowavePersistenceLayerMongoDb(p =>
{
p.WithDatabaseName("MyDatabase");
});
}
In the Action you should configure microwave by giving Microwave the
URIs to
the other services, so it can start discovering the servicenetwork by itself. You can do this like shown above by
adding URLs to the ServiceLocations of the config.
It will call the
services and ask what
events they are providing, so it can start the async handling processes. You also have to register a persistence
layer. In this example a MongoDb is registered with the extension method AddMicrowavePersistenceLayerMongoDb
Now you should be able to start the services and the read side will update when something on the write side happens, provided you defined some handlers. Of course you can implement the read side on the write side, too.
The Packages are also available in smaller chunks, like Microwave.Eventstores, Microwave.Domain, etc. if you want them to be used in other projects.
To choose a database type you have to pass a IPersistenceLayer
to the extension method when registering microwave.
Right now there is a Adapter for MongoDb which comes with a class MongoDbPersistenceLayer
that can be used register
the MongoDb dependencies. With the properties of the MongoDbPersistenceLayer
you can pass details for the used
database, such as connectionstring and datbase name. If nothing is passed, Microwave writes into the default database.
To use the microwave UI, install the nuget Package "Microwave.UI" and register it in the startup class. You also have to set the compatibility version to 2.1 or 2.2 to make the UI work. For some odd reason 2.0 does not work and the UI routes will always return a 404.
dotnet add package Microwave.UI
using Microwave;
using Microwave.UI;
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2); // 2.1 or 2.2 is needed
...
services.AddMicrowaveUI();
}
public void Configure(IApplicationBuilder app)
{
...
app.UseMicrowaveUI();
}