Skip to content

Commit a7b124c

Browse files
committed
#15 starting to work with SignalR on Generic Host
1 parent 553155c commit a7b124c

35 files changed

+376
-111
lines changed

README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
# Cloud Native .NET Core Kit
2-
[![Price](https://img.shields.io/badge/price-FREE-0098f7.svg?style=for-the-badge)](https://github.com/cloudnative-netcore/netcorekit/blob/master/LICENSE) [![version](https://img.shields.io/nuget/v/NetCoreKit.Domain.svg?label=version&style=for-the-badge)](https://www.nuget.org/packages?q=NetCoreKit)
3-
[![Build status](https://img.shields.io/appveyor/ci/thangchung/netcore-kit.svg?style=for-the-badge)](https://ci.appveyor.com/api/project/thangchung/netcore-kit)
1+
# Cloud-native .NET Core Kit
2+
[![Price](https://img.shields.io/badge/price-FREE-0098f7.svg)](https://github.com/cloudnative-netcore/netcorekit/blob/master/LICENSE)
3+
[![version](https://img.shields.io/nuget/v/NetCoreKit.Domain.svg?label=version)](https://www.nuget.org/packages?q=NetCoreKit)
4+
[![Build status](https://img.shields.io/appveyor/ci/thangchung/netcore-kit.svg)](https://ci.appveyor.com/api/project/thangchung/netcore-kit)
45

5-
A set of cloud native tools and utilities for .NET Core.
6+
A set of cloud-native tools and utilities for .NET Core.
7+
8+
<details>
9+
<summary>Features</summary>
610

7-
### Features
811
- Simple libraries. No frameworks. Little abstraction.
9-
- Modular (Easy to swap out Utils, Domain, AspNetCore, Clean Architecture, Open API, Entity Framework Core...)
12+
- Modular (Easy to swap out Utils, Domain, AspNetCore, Clean Architecture, Open API, Entity Framework Core, Event Bus...)
1013
- Adhere to [twelve-factor app paradigm](https://12factor.net) and more.
1114
- Resilience and health check out of the box.
1215
- Easy for configuration management.
@@ -17,7 +20,9 @@ A set of cloud native tools and utilities for .NET Core.
1720
- Documentation template with OpenAPI documentation.
1821
- Work natively with Kubernetes or even with Service Mesh.
1922

20-
### Get Starting
23+
</details>
24+
25+
## Less Code to Get Starting
2126

2227
Small, lightweight, cloud-native out of the box, and much more simple to get starting with miniservices approach. [Why miniservices?](https://thenewstack.io/miniservices-a-realistic-alternative-to-microservices)
2328

@@ -42,19 +47,22 @@ public class Startup
4247
}
4348
```
4449

45-
- Read [Get starting](https://github.com/cloudnative-netcore/netcorekit/wiki/Get-Started) section and [Play with Kubernetes](https://github.com/cloudnative-netcore/netcorekit/wiki/Deploy-on-k8s-on-local) section to know more about this cloud-native toolkit.
50+
<details>
51+
<summary>More types of equipment to get starting</summary>
4652

53+
- Read [Get starting](https://github.com/cloudnative-netcore/netcorekit/wiki/Get-Started) section and [Play with Kubernetes](https://github.com/cloudnative-netcore/netcorekit/wiki/Deploy-on-k8s-on-local) section to know more about this cloud-native toolkit.
4754
- Basic usage can be found at [TodoApi Sample](https://github.com/cloudnative-netcore/netcorekit/tree/master/samples/TodoApi)
4855
- More advance usage is at [Coolstore Microservices](https://github.com/vietnam-devs/coolstore-microservices) project.
4956

50-
### Contributing
57+
</details>
58+
59+
<details>
60+
<summary>Contributing</summary>
5161

5262
1. Fork it!
5363
2. Create your feature branch: `git checkout -b my-new-feature`
5464
3. Commit your changes: `git commit -am 'Add some feature'`
5565
4. Push to the branch: `git push origin my-new-feature`
5666
5. Submit a pull request :p
5767

58-
### Licence
59-
60-
Code released under [the MIT license](https://github.com/cloudnative-netcore/netcorekit/blob/master/LICENSE).
68+
</details>

netcorekit.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreKit.Infrastructure.B
5252
EndProject
5353
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreKit.Samples.Notifier", "samples\Notifier\NetCoreKit.Samples.Notifier.csproj", "{7AE8F281-2C86-4CF5-80CF-FCCE940E5DC3}"
5454
EndProject
55+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreKit.Samples.SignalRNotifier", "samples\SignalRNotifier\NetCoreKit.Samples.SignalRNotifier.csproj", "{9894E768-600D-452E-9F9E-6612D7AA6421}"
56+
EndProject
57+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreKit.Samples.Contracts", "samples\Contracts\NetCoreKit.Samples.Contracts.csproj", "{C7C5DA44-023A-4138-8F13-D7FA2EB58F74}"
58+
EndProject
5559
Global
5660
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5761
Debug|Any CPU = Debug|Any CPU
@@ -172,6 +176,22 @@ Global
172176
{7AE8F281-2C86-4CF5-80CF-FCCE940E5DC3}.Release|Any CPU.Build.0 = Release|Any CPU
173177
{7AE8F281-2C86-4CF5-80CF-FCCE940E5DC3}.Release|x86.ActiveCfg = Release|Any CPU
174178
{7AE8F281-2C86-4CF5-80CF-FCCE940E5DC3}.Release|x86.Build.0 = Release|Any CPU
179+
{9894E768-600D-452E-9F9E-6612D7AA6421}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
180+
{9894E768-600D-452E-9F9E-6612D7AA6421}.Debug|Any CPU.Build.0 = Debug|Any CPU
181+
{9894E768-600D-452E-9F9E-6612D7AA6421}.Debug|x86.ActiveCfg = Debug|Any CPU
182+
{9894E768-600D-452E-9F9E-6612D7AA6421}.Debug|x86.Build.0 = Debug|Any CPU
183+
{9894E768-600D-452E-9F9E-6612D7AA6421}.Release|Any CPU.ActiveCfg = Release|Any CPU
184+
{9894E768-600D-452E-9F9E-6612D7AA6421}.Release|Any CPU.Build.0 = Release|Any CPU
185+
{9894E768-600D-452E-9F9E-6612D7AA6421}.Release|x86.ActiveCfg = Release|Any CPU
186+
{9894E768-600D-452E-9F9E-6612D7AA6421}.Release|x86.Build.0 = Release|Any CPU
187+
{C7C5DA44-023A-4138-8F13-D7FA2EB58F74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
188+
{C7C5DA44-023A-4138-8F13-D7FA2EB58F74}.Debug|Any CPU.Build.0 = Debug|Any CPU
189+
{C7C5DA44-023A-4138-8F13-D7FA2EB58F74}.Debug|x86.ActiveCfg = Debug|Any CPU
190+
{C7C5DA44-023A-4138-8F13-D7FA2EB58F74}.Debug|x86.Build.0 = Debug|Any CPU
191+
{C7C5DA44-023A-4138-8F13-D7FA2EB58F74}.Release|Any CPU.ActiveCfg = Release|Any CPU
192+
{C7C5DA44-023A-4138-8F13-D7FA2EB58F74}.Release|Any CPU.Build.0 = Release|Any CPU
193+
{C7C5DA44-023A-4138-8F13-D7FA2EB58F74}.Release|x86.ActiveCfg = Release|Any CPU
194+
{C7C5DA44-023A-4138-8F13-D7FA2EB58F74}.Release|x86.Build.0 = Release|Any CPU
175195
EndGlobalSection
176196
GlobalSection(SolutionProperties) = preSolution
177197
HideSolutionNode = FALSE
@@ -192,6 +212,8 @@ Global
192212
{BEA4FAB4-1A38-4720-8CCB-D7074CF7596D} = {6CF50533-EBD6-47B1-9AD9-9EBBFF3AC887}
193213
{4C788CCD-4695-4A1E-8F8D-AD1C864C7AFA} = {6CF50533-EBD6-47B1-9AD9-9EBBFF3AC887}
194214
{7AE8F281-2C86-4CF5-80CF-FCCE940E5DC3} = {92D6FD73-B95C-4CBB-A48E-047672EB4E77}
215+
{9894E768-600D-452E-9F9E-6612D7AA6421} = {92D6FD73-B95C-4CBB-A48E-047672EB4E77}
216+
{C7C5DA44-023A-4138-8F13-D7FA2EB58F74} = {92D6FD73-B95C-4CBB-A48E-047672EB4E77}
195217
EndGlobalSection
196218
GlobalSection(ExtensibilityGlobals) = postSolution
197219
SolutionGuid = {B9325AE8-21A8-4D46-9B04-38BD2BC35C0F}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using MediatR;
22
using NetCoreKit.Domain;
33

4-
namespace NetCoreKit.Samples.TodoAPI.Domain
4+
namespace NetCoreKit.Samples.Contracts.Events
55
{
66
public class ProjectCreated : EventBase, INotification
77
{
@@ -10,6 +10,6 @@ public ProjectCreated(string name)
1010
Name = name;
1111
}
1212

13-
public string Name { get; set; }
13+
public string Name { get; }
1414
}
1515
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using MediatR;
2+
using NetCoreKit.Domain;
3+
4+
namespace NetCoreKit.Samples.Contracts.Events
5+
{
6+
public class TaskCreated : EventBase, INotification
7+
{
8+
public TaskCreated(string title)
9+
{
10+
Title = title;
11+
}
12+
public string Title { get; }
13+
}
14+
}

samples/TodoApi/Domain/TaskDeleted.cs renamed to samples/Contracts/Events/TaskDeleted.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using NetCoreKit.Domain;
22

3-
namespace NetCoreKit.Samples.TodoAPI.Domain
3+
namespace NetCoreKit.Samples.Contracts.Events
44
{
55
public class TaskDeleted : EventBase
66
{

samples/TodoApi/Domain/TaskUpdated.cs renamed to samples/Contracts/Events/TaskUpdated.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using NetCoreKit.Domain;
22

3-
namespace NetCoreKit.Samples.TodoAPI.Domain
3+
namespace NetCoreKit.Samples.Contracts.Events
44
{
55
public class TaskUpdated : EventBase
66
{
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="MediatR" Version="5.1.0" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\..\src\NetCoreKit.Domain\NetCoreKit.Domain.csproj" />
13+
</ItemGroup>
14+
15+
</Project>

samples/Notifier/EventsHostedService.cs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
4-
using AutoMapper;
54
using MediatR;
65
using Microsoft.Extensions.Hosting;
76
using Microsoft.Extensions.Logging;
87
using NetCoreKit.Domain;
9-
using NetCoreKit.Infrastructure.Mappers;
8+
using NetCoreKit.Samples.Contracts.Events;
109

1110
namespace NetCoreKit.Samples.Notifier
1211
{
@@ -44,7 +43,7 @@ private void OnStarted()
4443
{
4544
_logger.LogInformation("OnStarted has been called.");
4645

47-
_eventBus.Subscribe<ProjectCreated>().Wait();
46+
_eventBus.Subscribe("project").Wait();
4847
}
4948

5049
private void OnStopping()
@@ -61,24 +60,6 @@ private void OnStopped()
6160
}
6261
}
6362

64-
public class ProjectCreatedProfile : Profile
65-
{
66-
public ProjectCreatedProfile()
67-
{
68-
this.MapMySelf(typeof(ProjectCreated));
69-
}
70-
}
71-
72-
public class ProjectCreated : EventBase, INotification
73-
{
74-
public ProjectCreated(string name)
75-
{
76-
Name = name;
77-
}
78-
79-
public string Name { get; set; }
80-
}
81-
8263
public class ProjectCreatedSubscriber : INotificationHandler<ProjectCreated>
8364
{
8465
private readonly ILogger _logger;
@@ -91,7 +72,6 @@ public ProjectCreatedSubscriber(ILogger<ProjectCreatedSubscriber> logger)
9172
public Task Handle(ProjectCreated @event, CancellationToken cancellationToken)
9273
{
9374
_logger.LogInformation($"@ Project Created Event -{@event.OccurredOn}-{@event.EventVersion}. Now I will do something cool in this worker...");
94-
9575
return Task.FromResult(@event);
9676
}
9777
}

samples/Notifier/NetCoreKit.Samples.Notifier.csproj

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,11 @@
2525
<Content Include="**\*.json" CopyToOutputDirectory="PreserveNewest" />
2626
</ItemGroup>
2727

28-
<ItemGroup>
29-
<Compile Remove="bin\**" />
30-
<Compile Remove="obj\**" />
31-
<Content Remove="bin\**" />
32-
<Content Remove="obj\**" />
33-
<EmbeddedResource Remove="bin\**" />
34-
<EmbeddedResource Remove="obj\**" />
35-
<None Remove="bin\**" />
36-
<None Remove="obj\**" />
37-
</ItemGroup>
38-
3928
<ItemGroup>
4029
<ProjectReference Include="..\..\src\NetCoreKit.Domain\NetCoreKit.Domain.csproj" />
4130
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.Bus.Kafka\NetCoreKit.Infrastructure.Bus.Kafka.csproj" />
4231
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure\NetCoreKit.Infrastructure.csproj" />
32+
<ProjectReference Include="..\Contracts\NetCoreKit.Samples.Contracts.csproj" />
4333
</ItemGroup>
4434

4535
<ItemGroup>

samples/Notifier/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ public static async Task Main(string[] args)
2121
{
2222
configHost.SetBasePath(Directory.GetCurrentDirectory());
2323
configHost.AddJsonFile("hostsettings.json", optional: true);
24-
configHost.AddEnvironmentVariables(prefix: "PREFIX_");
24+
configHost.AddEnvironmentVariables();
2525
configHost.AddCommandLine(args);
2626
})
2727
.ConfigureAppConfiguration((hostContext, configApp) =>
2828
{
2929
configApp.AddJsonFile("appsettings.json", optional: true);
3030
configApp.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true);
31-
configApp.AddEnvironmentVariables(prefix: "PREFIX_");
31+
configApp.AddEnvironmentVariables();
3232
configApp.AddCommandLine(args);
3333
})
3434
.ConfigureServices((hostContext, services) =>

0 commit comments

Comments
 (0)