Skip to content

Commit d2e6ee9

Browse files
committed
fix bug #15
1 parent 1be6273 commit d2e6ee9

21 files changed

+136
-125
lines changed

samples/SignalRNotifier/Services/Hubs/ProjectHub.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Threading.Tasks;
33
using MediatR;
44
using Microsoft.AspNetCore.SignalR;
5+
using Microsoft.Extensions.Logging;
56
using NetCoreKit.Infrastructure.Bus.Kafka;
67
using Project.Proto;
78

@@ -16,29 +17,43 @@ public class ProjectHostService : HostedService,
1617
INotificationHandler<Notifications.TaskCreated>
1718
{
1819
private readonly IDispatchedEventBus _eventBus;
20+
private readonly ILogger<ProjectHostService> _logger;
1921

20-
public ProjectHostService(IHubContext<ProjectHub> context, IDispatchedEventBus eventBus)
22+
public ProjectHostService(IHubContext<ProjectHub> context, IDispatchedEventBus eventBus, ILoggerFactory loggerFactory)
2123
{
2224
_eventBus = eventBus;
2325
Clients = context.Clients;
26+
_logger = loggerFactory.CreateLogger<ProjectHostService>();
2427
}
2528

2629
private IHubClients Clients { get; }
2730

2831
public async Task Handle(Notifications.ProjectCreated notification, CancellationToken cancellationToken)
2932
{
33+
_logger.LogInformation("Pushing message to projectCreatedNotify...");
3034
await Clients.All.SendAsync("projectCreatedNotify", notification, cancellationToken);
3135
}
3236

3337
public async Task Handle(Notifications.TaskCreated notification, CancellationToken cancellationToken)
3438
{
39+
_logger.LogInformation("Pushing message to taskAddedToProjectNotify...");
3540
await Clients.All.SendAsync("taskAddedToProjectNotify", notification, cancellationToken);
3641
}
3742

3843
protected override Task ExecuteAsync(CancellationToken cancellationToken)
3944
{
40-
Task.Run(() => _eventBus.Subscribe<ProjectCreatedMsg>("project-created"), cancellationToken);
41-
Task.Run(() => _eventBus.Subscribe<TaskCreatedMsg>("task-created"), cancellationToken);
45+
Task.Run(() =>
46+
{
47+
_logger.LogInformation("[NCK] Start to subscribe to project-created...");
48+
return _eventBus.Subscribe<ProjectCreatedMsg>("project-created");
49+
}, cancellationToken);
50+
51+
Task.Run(() =>
52+
{
53+
_logger.LogInformation("[NCK] Start to subscribe to task-created...");
54+
return _eventBus.Subscribe<TaskCreatedMsg>("task-created");
55+
}, cancellationToken);
56+
4257
return Task.CompletedTask;
4358
}
4459
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"Hosts": {
3-
"BasePath": "/"
2+
"EventBus": {
3+
"Brokers": "127.0.0.1:9092"
44
}
55
}

samples/SignalRNotifier/appsettings.json

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
{
2-
"EventBus": {
3-
"Brokers": "127.0.0.1:9092"
4-
},
52
"Hosts": {
6-
"BasePath": "/api/"
3+
"BasePath": "/"
4+
},
5+
"EventBus": {
6+
"Brokers": "PLAINTEXT://kafka-cp-kafka:9092"
77
},
88
"Logging": {
99
"IncludeScopes": false,
10-
"LogLevel": {
11-
"Default": "Debug",
12-
"System": "Information",
13-
"Microsoft": "Information"
10+
"Debug": {
11+
"LogLevel": {
12+
"Default": "Warning"
13+
}
14+
},
15+
"Console": {
16+
"LogLevel": {
17+
"Default": "Debug",
18+
"System": "Information",
19+
"Microsoft": "Information"
20+
}
1421
}
1522
},
1623
"AllowedHosts": "*"

samples/SignalRNotifier/k8s/signalrnotifier-dep.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ spec:
1717
imagePullPolicy: IfNotPresent
1818
env:
1919
- name: Hosts__BasePath
20-
value: /notifier/
20+
value: /
2121
- name: EventBus__Brokers
22-
value: kafka:9092
22+
value: PLAINTEXT://kafka-cp-kafka:9092
2323
ports:
2424
- containerPort: 5002
2525
resources:
@@ -28,4 +28,4 @@ spec:
2828
cpu: "250m"
2929
limits:
3030
memory: "128Mi"
31-
cpu: "500m"
31+
cpu: "500m"

samples/TodoApi/Migrations/20180901072324_InitTodoDb.Designer.cs renamed to samples/TodoApi/Migrations/20180921105440_InitToDoDb.Designer.cs

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/TodoApi/Migrations/20180901072324_InitTodoDb.cs renamed to samples/TodoApi/Migrations/20180921105440_InitToDoDb.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace NetCoreKit.Samples.TodoAPI.Migrations
55
{
6-
public partial class InitTodoDb : Migration
6+
public partial class InitToDoDb : Migration
77
{
88
protected override void Up(MigrationBuilder migrationBuilder)
99
{

samples/TodoApi/Migrations/TodoListDbContextModelSnapshot.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1414
{
1515
#pragma warning disable 612, 618
1616
modelBuilder
17-
.HasAnnotation("ProductVersion", "2.1.2-rtm-30932");
17+
.HasAnnotation("ProductVersion", "2.1.2-rtm-30932")
18+
.HasAnnotation("Relational:MaxIdentifierLength", 64);
1819

1920
modelBuilder.Entity("NetCoreKit.Samples.TodoAPI.Domain.Project", b =>
2021
{

samples/TodoApi/Startup.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public void ConfigureServices(IServiceCollection services)
1717
services.AddMiniService<TodoListDbContext>(
1818
svc =>
1919
{
20-
svc.AddEfSqlLiteDb();
21-
//svc.AddEfCoreMySqlDb();
22-
//svc.AddExternalSystemHealthChecks();
20+
// svc.AddEfSqlLiteDb();
21+
svc.AddEfCoreMySqlDb();
22+
svc.AddExternalSystemHealthChecks();
2323
svc.AddKafkaEventBus();
2424
},
2525
(svc, _) => { svc.AddScoped<IUserGateway, UserGateway>(); }
Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
{
22
"ConnectionStrings": {
33
"mssqldb": "Server=tcp:127.0.0.1,1433;Database=maindb;User Id=cs;Password=P@ssw0rd;",
4-
"mysqldb": "server=127.0.0.1;port=3306;uid=root;pwd=P@ssw0rd;database=maindb"
4+
"mysqldb": "server=127.0.0.1;port=30139;uid=root;pwd=P@ssw0rd;database=maindb"
55
},
6-
"Hosts": {
7-
"Externals": {
8-
"CurrentUri": "http://localhost:5001"
9-
}
10-
},
11-
"Logging": {
12-
"IncludeScopes": false,
13-
"LogLevel": {
14-
"Default": "Debug",
15-
"System": "Information",
16-
"Microsoft": "Information"
17-
}
18-
}
6+
"Hosts": {
7+
"Externals": {
8+
"CurrentUri": "http://localhost:5001"
9+
}
10+
},
11+
"EventBus": {
12+
"Brokers": "127.0.0.1:9092"
13+
},
14+
"Logging": {
15+
"IncludeScopes": false,
16+
"LogLevel": {
17+
"Default": "Debug",
18+
"System": "Information",
19+
"Microsoft": "Information"
20+
}
21+
}
1922
}

samples/TodoApi/appsettings.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
},
88
"k8s": {
99
"mysqldb": {
10-
"ServiceName": "todolistdb",
10+
"ServiceName": "mysql",
1111
"Database": "maindb",
1212
"UserName": "root",
1313
"Password": "P@ssw0rd",
14-
"Major": 8,
15-
"Minor": 0,
16-
"Build": 12,
14+
"Major": 5,
15+
"Minor": 7,
16+
"Build": 14,
1717
"DbType": 0
1818
}
1919
},
@@ -24,11 +24,11 @@
2424
"Hosts": {
2525
"BasePath": "/",
2626
"Externals": {
27-
"CurrentUri": "http://localhost:5001"
27+
"CurrentUri": "http://localhost:32501"
2828
}
2929
},
3030
"EventBus": {
31-
"Brokers": "127.0.0.1:9092"
31+
"Brokers": "PLAINTEXT://kafka-cp-kafka:9092"
3232
},
3333
"Logging": {
3434
"IncludeScopes": false,

0 commit comments

Comments
 (0)