-
-
Notifications
You must be signed in to change notification settings - Fork 70
Get Started
Thang Chung edited this page Oct 30, 2018
·
6 revisions
- Open up the
netcore-kit.sln
- Start with the project
NetCoreKit.Samples.TodoAPI
- Then press
F5
, we should see OpenAPI UI ofsamples\TodoApi
sample - Just play around with it.
- Open up the
netcore-kit.sln
- Start with the project
NetCoreKit.Samples.TodoAPI
- SQL Server
> docker run --name sqlserverdb -p 1433:1433 -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD=Passw0rd microsoft/mssql-server-linux:2017-latest
- MySQL
> docker run --name mysqldb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=P@ssw0rd -e MYSQL_PASSWORD=P@ssw0rd mysql:8.0.12
- Add middleware in
samples\TodoApi\Startup.cs
as following
services.AddMiniService<TodoDbContext>(
new[] {typeof(Startup)},
svc =>
{
// svc.AddEfCoreSqlServerDb();
svc.AddEfCoreMySqlDb();
svc.AddExternalSystemHealthChecks();
});
- Put connection string for each type of database into
ConnectionStrings
section in theappsettings.json
file as below
"mssqldb": "Server=tcp:127.0.0.1,1433;Database=maindb;User Id=cs;Password=P@ssw0rd;"
"mysqldb": "server=127.0.0.1;port=3306;uid=root;pwd=P@ssw0rd;database=maindb"
If you run it on Kubernetes
:
"k8s": {
"mysqldb": {
"Host": "TODOLISTDB_SERVICE_HOST",
"Port": "TODOLISTDB_SERVICE_PORT",
"Database": "maindb",
"UserName": "root",
"Password": "P@ssw0rd",
"Major": 8,
"Minor": 0,
"Build": 12,
"DbType": 0
}
}
- Then press
F5
- Open up the
netcore-kit.sln
- Start with 2 projects
NetCoreKit.Samples.TodoAPI
andNetCoreKit.Samples.Notifier
> docker run -d -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=127.0.0.1 --env ADVERTISED_PORT=9092 spotify/kafka
- Change
appsettings.json
forNetCoreKit.Samples.TodoAPI
andNetCoreKit.Samples.Notifier
as following
"EventBus": {
"Brokers": "127.0.0.1:9092"
}
- Change code for projects
// publisher
services.AddMiniService<TodoListDbContext>(
svc =>
{
svc.AddKafkaEventBus();
}
);
// subcriber
services.AddKafkaEventBus();
- Press
F5
, then try to createa new project
on theOpenAPI UI
- See the subscriber work on the notifier.
Notes: To generating protobuf contract, please follow the guidance
> cd <to-root-of-project>
> protoc samples\protos\project.proto --csharp_out .\samples\Contracts