Skip to content

Commit 3b2eef7

Browse files
committed
refactor code
1 parent 587bfa7 commit 3b2eef7

27 files changed

+143
-82
lines changed

netcorekit.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreKit.Samples.WebNotif
6363
EndProject
6464
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreKit.Infrastructure.Bus.Redis", "src\NetCoreKit.Infrastructure.Bus.Redis\NetCoreKit.Infrastructure.Bus.Redis.csproj", "{94E34AF7-42CA-4BBC-B444-FC17915B4D55}"
6565
EndProject
66+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "protos", "protos", "{B955EE6A-DBD9-474A-AE34-E1960E887F0F}"
67+
ProjectSection(SolutionItems) = preProject
68+
samples\protos\project.proto = samples\protos\project.proto
69+
EndProjectSection
70+
EndProject
6671
Global
6772
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6873
Debug|Any CPU = Debug|Any CPU
@@ -239,6 +244,7 @@ Global
239244
{C7C5DA44-023A-4138-8F13-D7FA2EB58F74} = {92D6FD73-B95C-4CBB-A48E-047672EB4E77}
240245
{02E8D785-5013-47B2-BFC6-371874C8BA64} = {92D6FD73-B95C-4CBB-A48E-047672EB4E77}
241246
{94E34AF7-42CA-4BBC-B444-FC17915B4D55} = {6CF50533-EBD6-47B1-9AD9-9EBBFF3AC887}
247+
{B955EE6A-DBD9-474A-AE34-E1960E887F0F} = {92D6FD73-B95C-4CBB-A48E-047672EB4E77}
242248
EndGlobalSection
243249
GlobalSection(ExtensibilityGlobals) = postSolution
244250
SolutionGuid = {B9325AE8-21A8-4D46-9B04-38BD2BC35C0F}

samples/SignalRNotifier/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
FROM microsoft/dotnet:2.1.5-aspnetcore-runtime-alpine AS base
22
WORKDIR /app
33

4-
ENV ASPNETCORE_URLS http://+:5002
5-
EXPOSE 5002
4+
ENV ASPNETCORE_URLS http://+:80
5+
EXPOSE 80
66

77
FROM microsoft/dotnet:2.1.403-sdk-alpine AS build
88
WORKDIR .

samples/SignalRNotifier/Startup.cs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
using Microsoft.Extensions.Hosting;
99
using Microsoft.Extensions.Logging;
1010
using NetCoreKit.Infrastructure.AspNetCore.Configuration;
11-
using NetCoreKit.Infrastructure.AspNetCore.Extensions;
1211
using NetCoreKit.Infrastructure.Bus;
13-
using NetCoreKit.Infrastructure.Bus.Kafka;
1412
using NetCoreKit.Infrastructure.Bus.Redis;
1513
using NetCoreKit.Samples.SignalRNotifier.Services.Hubs;
1614
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
@@ -23,12 +21,10 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
2321
{
2422
services.AddMediatR(
2523
typeof(Startup),
26-
typeof(DomainEventBus)
27-
/*typeof(ProjectCreated)*/);
24+
typeof(DomainEventBus));
2825

2926
Mapper.Initialize(cfg => cfg.AddProfiles(typeof(Startup)));
3027

31-
// services.AddKafkaEventBus();
3228
services.AddRedisBus();
3329
services.AddSignalR();
3430
services.AddSingleton<IHostedService, ProjectHostService>();
@@ -79,26 +75,12 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
7975
private static IServiceProvider BuildServiceProvider(IServiceCollection services)
8076
{
8177
var resolver = services.BuildServiceProvider();
82-
var config = resolver.GetRequiredService<IConfiguration>();
83-
var env = resolver.GetRequiredService<IHostingEnvironment>();
84-
var kafkaOptions = config.GetSection("Kafka");
85-
//if (env.IsDevelopment())
86-
{
87-
services.Configure<KafkaOptions>(o => { o.Fqdn = kafkaOptions.GetValue<string>("FQDN"); });
88-
}
89-
/*else
90-
{
91-
var serviceName = kafkaOptions
92-
.GetValue("ServiceName", "kafka")
93-
.Replace("-", "_")
94-
.ToUpperInvariant();
95-
96-
var ip = Environment.GetEnvironmentVariable($"{serviceName}_SERVICE_HOST");
97-
var port = Environment.GetEnvironmentVariable($"{serviceName}_SERVICE_PORT");
98-
99-
services.Configure<KafkaOptions>(o => { o.Fqdn = $"{ip}:{port}"; });
100-
}*/
78+
//var config = resolver.GetRequiredService<IConfiguration>();
79+
//var env = resolver.GetRequiredService<IHostingEnvironment>();
10180

81+
// TODO: let register options here
82+
// ...
83+
10284
return resolver;
10385
}
10486
}

samples/SignalRNotifier/appsettings.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
"Hosts": {
44
"BasePath": "/"
55
},
6-
"Kafka": {
7-
"FQDN": "kafka-cp-kafka:9092"
8-
},
9-
"Redis": {
10-
"FQDN": "redis-master.redis:6379",
11-
"Password": "letmein"
12-
},
136
"Logging": {
147
"IncludeScopes": false,
158
"Debug": {

samples/SignalRNotifier/build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
set -e
3+
set -x
4+
5+
export ASPNETCORE_ENVIRONMENT Development
6+
dotnet build
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -e
3+
set -x
4+
5+
TAG=${TAG:=$(git rev-parse --short HEAD)}
6+
NAMESPACE=${NAMESPACE:="vndg"}
7+
echo "${NAMESPACE} and ${TAG}"
8+
9+
echo "Build SignalR..."
10+
docker build -f samples/SignalRNotifier/Dockerfile -t vndg/signalrnotifier:$(git rev-parse --short HEAD) -t vndg/signalrnotifier:latest .

samples/SignalRNotifier/k8s/signalrnotifier-dep.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ spec:
1818
env:
1919
- name: Hosts__BasePath
2020
value: /
21-
- name: EventBus__FQDN
22-
value: "kafka-cp-kafka:9092"
23-
- name: Redis__Connection
21+
- name: Kafka__FQDN
22+
value: "kafka-cp-kafka.kafka:9092"
23+
- name: Redis__FQDN
2424
value: "redis-master.redis:6379"
2525
- name: Redis__Password
2626
value: "letmein"
2727
ports:
28-
- containerPort: 5002
28+
- containerPort: 80

samples/SignalRNotifier/k8s/signalrnotifier-svc.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ metadata:
88
spec:
99
ports:
1010
- port: 32502
11-
targetPort: 5002
11+
targetPort: 80
1212
nodePort: 32502
1313
protocol: TCP
1414
name: http
1515
type: LoadBalancer
1616
selector:
17-
app: signalrnotifier
17+
app: signalrnotifier

samples/SignalRNotifier/start.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
set -e
3+
set -x
4+
5+
dotnet run

samples/TodoApi/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ ENV SERVICE_VERSION ${service_version:-0.0.1}
77
ARG api_version
88
ENV API_VERSION ${api_version:-1.0}
99

10-
ENV ASPNETCORE_URLS http://+:5001
11-
EXPOSE 5001
10+
ENV ASPNETCORE_URLS http://+:80
11+
EXPOSE 80
1212

1313
FROM microsoft/dotnet:2.1.403-sdk-alpine AS build
1414
WORKDIR .

0 commit comments

Comments
 (0)