Workleap.DomainEventPropagation.Publishing.ApplicationInsights
0.1.1-preview.2
Prefix Reserved
See the version list below for details.
dotnet add package Workleap.DomainEventPropagation.Publishing.ApplicationInsights --version 0.1.1-preview.2
NuGet\Install-Package Workleap.DomainEventPropagation.Publishing.ApplicationInsights -Version 0.1.1-preview.2
<PackageReference Include="Workleap.DomainEventPropagation.Publishing.ApplicationInsights" Version="0.1.1-preview.2" />
paket add Workleap.DomainEventPropagation.Publishing.ApplicationInsights --version 0.1.1-preview.2
#r "nuget: Workleap.DomainEventPropagation.Publishing.ApplicationInsights, 0.1.1-preview.2"
// Install Workleap.DomainEventPropagation.Publishing.ApplicationInsights as a Cake Addin #addin nuget:?package=Workleap.DomainEventPropagation.Publishing.ApplicationInsights&version=0.1.1-preview.2&prerelease // Install Workleap.DomainEventPropagation.Publishing.ApplicationInsights as a Cake Tool #tool nuget:?package=Workleap.DomainEventPropagation.Publishing.ApplicationInsights&version=0.1.1-preview.2&prerelease
Workleap.DomainEventPropagation
These libraries must be used in conjunction with Azure Event Grid in order to publish and receive domain events. It is meant to be used in a multi-services architecture where each service is responsible for its own data and publishes events to notify other services of changes.
Getting started
Publish domain events
Install the package Workleap.DomainEventPropagation.Publishing in your .NET project that wants to send events to an Event Grid topic. Then, you can use one of the following methods to register the required services.
// Method 1: Automatically bind the options to a well-known configuration section
services.AddEventPropagationPublisher();
// appsetting.json (or any other configuration source)
{
"EventPropagation": {
"Publisher": {
"TopicEndpoint": "<azure_topic_uri>",
"TopicAccessKey": "<secret_value>"
}
}
}
// Method 2: Automatically bind the options to a well-known configuration section with Azure Identity (RBAC)
services.AddEventPropagationPublisher(options =>
{
options.TokenCredential = new DefaultAzureCredential();
});
// appsetting.json (or any other configuration source)
{
"EventPropagation": {
"Publisher": {
"TopicEndpoint": "<azure_topic_uri>"
}
}
}
// Method 3: Set options values directly in C#
services.AddEventPropagationPublisher(options =>
{
options.TopicEndpoint = "<azure_topic_uri>",
// Using an access key
options.TopicAccessKey = "<secret_value>"
// Using Azure Identity (RBAC)
options.TokenCredential = new DefaultAzureCredential();
});
Note that you can use either an access key or a token credential in order to authenticate to your eventGrid topic, not both.
Then, in order to publish a domain event, you first need to define your domain events using the IDomainEvent
interface.
Decorate the domain event with the [DomainEvent]
attribute, specifying a unique event name.
[DomainEvent("example")]
public class ExampleDomainEvent : IDomainEvent
{
public string Id { get; set; }
}
Once your domain events are defined, you can inject and use the IEventPropagationClient
service.
var domainEvent = new ExampleDomainEvent
{
Id = Guid.NewGuid().ToString()
};
await this._eventPropagationClient.PublishDomainEventAsync(domainEvent, CancellationToken.None);
Subscribe to domain events
Install the package Workleap.DomainEventPropagation.Subscription in your ASP.NET Core project that wants to receive events from Event Grid topics.
You can define your domain event handlers by implementing the IDomainEventHandler<>
interface and then registering them in the service collection later.
public class ExampleDomainEventHandler : IDomainEventHandler<ExampleDomainEvent>
{
public Task HandleDomainEventAsync(ExampleDomainEvent domainEvent, CancellationToken cancellationToken)
{
// Do something with the domain event
return Task.CompletedTask;
}
}
Then, you can use on of the following methods to register the required services and map the webhook endpoint.
// Method 1: Register only selected domain event handlers
services.AddEventPropagationSubscriber()
.AddDomainEventHandler<ExampleDomainEventHandler>()
.AddDomainEventHandler<OtherDomainEventHandler>();
// Method 2: Register all domain event handlers from a given assembly
services.AddEventPropagationSubscriber()
.AddDomainEventHandlersFromAssembly(Assembly.GetExecutingAssembly());
// Register the webhook endpoint in your ASP.NET Core app (startup-based approach)
app.UseEndpoints(builder =>
{
builder.MapEventPropagationEndpoint();
});
// Register the webhook endpoint in your ASP.NET Core app (minimal APIs approach)
app.MapEventPropagationEndpoint();
Securing the webhook endpoint
It is required to expose an ASP.NET Core endpoint in order for Event Grid topics to be able to push events. By default, the registered endpoint will allow anonymous access, but it is possible to secure it as shown below:
// "RequireAuthorization" is a built-in ASP.NET Core method so you can specify any authorization policy you want
app.MapEventPropagationEndpoint().RequireAuthorization();
Now, follow this Microsoft documentation to continue the configuration.
Additional notes
- You may only define one domain event handler per domain event you wish to handle. If you would require more, use the single allowed domain event handler as a facade for multiple operations.
- Domain event handlers must have idempotent behavior (you could execute it multiple times for the same event and the result would always be the same).
- If your domain event types and handlers are in dedicated assemblies, you can reference the Workleap.DomainEventPropagation.Abstractions packages in order to avoid a dependency on third-parties like Azure and Microsoft extensions.
Building, releasing and versioning
The project can be built by running Build.ps1
. It uses Microsoft.CodeAnalysis.PublicApiAnalyzers to help detect public API breaking changes. Use the built-in roslyn analyzer to ensure that public APIs are declared in PublicAPI.Shipped.txt
, and obsolete public APIs in PublicAPI.Unshipped.txt
.
A new preview NuGet package is automatically published on any new commit on the main branch. This means that by completing a pull request, you automatically get a new NuGet package.
When you are ready to officially release a stable NuGet package by following the SemVer guidelines, simply manually create a tag with the format x.y.z
. This will automatically create and publish a NuGet package for this version.
License
Copyright © 2023, Workleap This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license at https://github.com/gsoft-inc/gsoft-license/blob/master/LICENSE.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.ApplicationInsights (>= 2.21.0)
- Workleap.DomainEventPropagation.Publishing (>= 0.1.1-preview.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.1-preview.9 | 41 | 12/18/2024 |
1.1.1-preview.8 | 36 | 12/18/2024 |
1.1.1-preview.7 | 38 | 12/17/2024 |
1.1.1-preview.6 | 41 | 11/29/2024 |
1.1.1-preview.5 | 44 | 11/17/2024 |
1.1.1-preview.4 | 39 | 10/30/2024 |
1.1.1-preview.3 | 44 | 10/28/2024 |
1.1.1-preview.2 | 39 | 10/28/2024 |
1.1.1-preview.1 | 38 | 10/28/2024 |
1.1.0 | 91 | 10/9/2024 |
1.0.2-preview.19 | 44 | 10/9/2024 |
1.0.2-preview.18 | 55 | 10/1/2024 |
1.0.2-preview.17 | 48 | 10/1/2024 |
1.0.2-preview.16 | 55 | 10/1/2024 |
1.0.2-preview.15 | 46 | 10/1/2024 |
1.0.2-preview.14 | 47 | 10/1/2024 |
1.0.2-preview.13 | 35 | 9/20/2024 |
1.0.2-preview.12 | 38 | 9/20/2024 |
1.0.2-preview.11 | 46 | 8/27/2024 |
1.0.2-preview.10 | 46 | 8/27/2024 |
1.0.2-preview.9 | 58 | 8/27/2024 |
1.0.2-preview.7 | 43 | 8/27/2024 |
1.0.2-preview.5 | 46 | 8/27/2024 |
1.0.2-preview.4 | 40 | 8/27/2024 |
1.0.2-preview.3 | 40 | 8/27/2024 |
1.0.2-preview.2 | 45 | 8/27/2024 |
1.0.1 | 108 | 8/20/2024 |
1.0.1-preview.2 | 66 | 8/20/2024 |
1.0.1-preview.1 | 68 | 8/16/2024 |
1.0.0 | 126 | 8/15/2024 |
0.6.2-preview.2 | 68 | 8/15/2024 |
0.6.2-preview.1 | 64 | 8/15/2024 |
0.6.1 | 121 | 8/15/2024 |
0.6.1-preview.5 | 69 | 8/14/2024 |
0.6.1-preview.4 | 60 | 8/14/2024 |
0.6.1-preview.3 | 59 | 8/12/2024 |
0.6.1-preview.2 | 37 | 8/5/2024 |
0.6.1-preview.1 | 46 | 7/26/2024 |
0.6.0 | 103 | 7/18/2024 |
0.5.6-preview.3 | 59 | 7/18/2024 |
0.5.6-preview.2 | 54 | 7/18/2024 |
0.5.6-preview.1 | 55 | 7/18/2024 |
0.5.5-preview.3 | 42 | 7/17/2024 |
0.5.5-preview.2 | 49 | 7/15/2024 |
0.5.4 | 123 | 6/19/2024 |
0.5.4-preview.5 | 53 | 6/17/2024 |
0.5.4-preview.4 | 53 | 6/17/2024 |
0.5.4-preview.3 | 54 | 6/14/2024 |
0.5.4-preview.2 | 52 | 6/14/2024 |
0.5.4-preview.1 | 54 | 6/13/2024 |
0.5.3 | 102 | 5/21/2024 |
0.5.3-preview.1 | 65 | 5/10/2024 |
0.5.2 | 122 | 4/17/2024 |
0.5.2-preview.2 | 67 | 4/12/2024 |
0.5.2-preview.1 | 63 | 4/8/2024 |
0.5.1 | 115 | 4/8/2024 |
0.5.1-preview.1 | 62 | 4/8/2024 |
0.4.1-preview.10 | 58 | 4/8/2024 |
0.4.1-preview.9 | 61 | 3/28/2024 |
0.4.1-preview.8 | 56 | 3/26/2024 |
0.4.1-preview.7 | 61 | 3/19/2024 |
0.4.1-preview.6 | 57 | 3/18/2024 |
0.4.1-preview.5 | 66 | 3/8/2024 |
0.4.1-preview.4 | 62 | 3/7/2024 |
0.4.1-preview.3 | 61 | 3/4/2024 |
0.4.1-preview.2 | 63 | 3/4/2024 |
0.4.1-preview.1 | 59 | 2/29/2024 |
0.4.0 | 119 | 2/27/2024 |
0.3.1-preview.6 | 60 | 2/26/2024 |
0.3.1-preview.5 | 57 | 2/26/2024 |
0.3.1-preview.4 | 62 | 2/23/2024 |
0.3.1-preview.3 | 57 | 2/16/2024 |
0.3.1-preview.2 | 61 | 2/6/2024 |
0.3.1-preview.1 | 63 | 2/6/2024 |
0.3.0 | 109 | 1/26/2024 |
0.2.1-preview.24 | 56 | 1/23/2024 |
0.2.1-preview.23 | 62 | 1/22/2024 |
0.2.1-preview.22 | 69 | 1/12/2024 |
0.2.1-preview.21 | 62 | 1/12/2024 |
0.2.1-preview.20 | 53 | 1/12/2024 |
0.2.1-preview.18 | 77 | 12/18/2023 |
0.2.1-preview.17 | 88 | 12/7/2023 |
0.2.1-preview.16 | 97 | 11/17/2023 |
0.2.1-preview.15 | 76 | 11/13/2023 |
0.2.1-preview.14 | 72 | 11/13/2023 |
0.2.1-preview.13 | 70 | 11/7/2023 |
0.2.1-preview.11 | 125 | 10/24/2023 |
0.2.1-preview.10 | 78 | 10/20/2023 |
0.2.1-preview.8 | 82 | 10/17/2023 |
0.2.1-preview.7 | 90 | 10/13/2023 |
0.2.1-preview.6 | 78 | 10/2/2023 |
0.2.1-preview.5 | 83 | 9/26/2023 |
0.2.1-preview.4 | 75 | 9/21/2023 |
0.2.1-preview.3 | 78 | 9/21/2023 |
0.2.1-preview.2 | 79 | 9/21/2023 |
0.2.1-preview.1 | 76 | 9/21/2023 |
0.2.0 | 160 | 9/21/2023 |
0.1.1-preview.6 | 72 | 9/20/2023 |
0.1.1-preview.5 | 72 | 9/20/2023 |
0.1.1-preview.4 | 81 | 9/19/2023 |
0.1.1-preview.3 | 86 | 9/13/2023 |
0.1.1-preview.2 | 90 | 9/13/2023 |
0.1.1-preview.1 | 92 | 9/11/2023 |
0.1.0 | 174 | 9/7/2023 |
0.1.0-preview.33 | 87 | 9/7/2023 |