(八)复习(拆分微服务) - 教程



项目地址

  • 教程作者:
  • 教程地址:
  • 代码仓库地址:
  • 所用到的框架和插件:
dbt
airflow

一、Ticketing模块拆分

1.1 创建web api

在这里插入图片描述

1. 添加引用

  • 删除program.cs里没有用的服务
    在这里插入图片描述

2. 添加需要的包和配置

  • Ticketing的webapi和Event.api一样,直接复制粘贴
    在这里插入图片描述
  • 将Event.api里的appsettings复制到改web api只留下自己相关的 appsettings.development.json
{
"ConnectionStrings": {
"Database": "Host=evently.database;Port=5432;Database=evently;Username=postgres;Password=postgres;Include Error Detail=true",
"Cache": "evently.redis:6379",
"Queue": "amqp://evently-queue:5672"
},
"Authentication": {
"Audience": "account",
"TokenValidationParameters": {
"ValidIssuers": [ "http://evently.identity:8080/realms/evently", "http://localhost:18080/realms/evently" ]
},
"MetadataAddress": "http://evently.identity:8080/realms/evently/.well-known/openid-configuration",
"RequireHttpsMetadata": false
},
"KeyCloak": {
"HealthUrl": "http://evently.identity:8080/health/"
},
"Serilog": {
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.Seq"
],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"Evently.Modules.Ticketing.Infrastructure.Outbox": "Warning",
"Evently.Modules.Ticketing.Infrastructure.Inbox": "Warning"
}
},
"WriteTo": [
{ "Name": "Console" },
{
"Name": "Seq",
"Args": { "serverUrl": "http://evently.seq:5341" }
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "Evently.Ticketing.Api"
}
},
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://evently.jaeger:4317"
}

3. program.cs

  • 删除所有需要其他模块的配置
    在这里插入图片描述

4. docker-compose修改

在这里插入图片描述

posted @ 2025-08-03 22:19  wzzkaifa  阅读(6)  评论(0)    收藏  举报