当前位置: 首页 > wzjs >正文

法治建设的网站站长工具seo推广

法治建设的网站,站长工具seo推广,静态网站的建设模板,乌市昌吉州建设局网站文章目录 项目地址一、OpenTelemetry1.1 配置OpenTelemetry1. 服务添加2. 添加服务标识3. 添加请求的标识4. 添加中间价 二、Rabbit MQ2.1 配置Rabbit MQ1. docker-compose2. 添加Rabbit MQ的Connect String 2.2 替换成Rabbit MQ1. 安装所需要的包2. 使用 三、API Gateways3.1 …

文章目录

  • 项目地址
  • 一、OpenTelemetry
    • 1.1 配置OpenTelemetry
      • 1. 服务添加
      • 2. 添加服务标识
      • 3. 添加请求的标识
      • 4. 添加中间价
  • 二、Rabbit MQ
    • 2.1 配置Rabbit MQ
      • 1. docker-compose
      • 2. 添加Rabbit MQ的Connect String
    • 2.2 替换成Rabbit MQ
      • 1. 安装所需要的包
      • 2. 使用
  • 三、API Gateways
    • 3.1 创建Gateway
      • 1. 配置docker-compose
      • 2. 添加各种服务
      • 3. 添加jwt配置
      • 4. 添加日志追踪
      • 5. 配置appsettings
      • 6. Yarp反向代理设置


项目地址

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

一、OpenTelemetry

1.1 配置OpenTelemetry

1. 服务添加

  1. namespace Evently.Common.Infrastructure; 配置
        services.AddOpenTelemetry().ConfigureResource(resource => resource.AddService(serviceName)).WithTracing(tracing =>{tracing.AddAspNetCoreInstrumentation().AddHttpClientInstrumentation().AddEntityFrameworkCoreInstrumentation().AddRedisInstrumentation().AddNpgsql().AddSource(MassTransit.Logging.DiagnosticHeaders.DefaultListenerName);tracing.AddOtlpExporter();});

2. 添加服务标识

在这里插入图片描述

  1. 创建服务标识
namespace Evently.Api.OpenTelemetry;public static class DiagnosticsConfig
{public const string ServiceName = "Evently.Api";
}
  1. program里注册
    在这里插入图片描述

3. 添加请求的标识

  • 在RequestLoggingPipelineBehavior添加的请求和服务的标识

在这里插入图片描述

4. 添加中间价

在这里插入图片描述

  • LogContextTraceLoggingMiddleware
namespace Evently.Api.Middleware;
internal sealed class LogContextTraceLoggingMiddleware(RequestDelegate next)
{public Task Invoke(HttpContext context){string traceId = Activity.Current?.TraceId.ToString();using (LogContext.PushProperty("TraceId", traceId)){return next.Invoke(context);}}
}
  • MiddlewareExtensions 用于将自定义日志追踪中间件 LogContextTraceLoggingMiddleware 添加到 ASP.NET Core 的中间件管道中。
namespace Evently.Api.Middleware;
internal static class MiddlewareExtensions
{internal static IApplicationBuilder UseLogContextTraceLogging(this IApplicationBuilder app){app.UseMiddleware<LogContextTraceLoggingMiddleware>();return app;}
}
  • 中间件添加
    在这里插入图片描述

二、Rabbit MQ

2.1 配置Rabbit MQ

1. docker-compose

  • docker-compose.yml
evently.queue:image: rabbitmq:management-alpinecontainer_name: Evently.Queuehostname: evently-queuevolumes:- ./.containers/queue/data/:/var/lib/rabbitmq- ./.containers/queue/log/:/var/log/rabbitmqenvironment:RABBITMQ_DEFAULT_USER: guestRABBITMQ_DEFAULT_PASS: guestports:- 5672:5672- 15672:15672

2. 添加Rabbit MQ的Connect String

  "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"},

2.2 替换成Rabbit MQ

1. 安装所需要的包

  • 替换之前内存为Rabbit MQ
  • 安装所需要的包
    <PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="8.0.1" /><PackageReference Include="MassTransit.RabbitMQ" Version="8.2.1" />
  1. 创建MQ配置文件
namespace Evently.Common.Infrastructure.EventBus;
public sealed record RabbitMqSettings(string Host, string Username = "guest", string Password = "guest");

2. 使用

  1. 修改MassTransit,将内存改为MQ
    在这里插入图片描述
  2. 注册Ticketing的消费者
    在这里插入图片描述
  3. 注册Event的消费者
    在这里插入图片描述
  4. Program里注册
    在这里插入图片描述

三、API Gateways

在这里插入图片描述

3.1 创建Gateway

在这里插入图片描述

1. 配置docker-compose

在这里插入图片描述

2. 添加各种服务

  • 在Gateway的program.cs里添加服务
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog((context, loggerConfig) => loggerConfig.ReadFrom.Configuration(context.Configuration));
builder.Services.AddReverseProxy().LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));builder.Services.AddOpenTelemetry().ConfigureResource(resource => resource.AddService(DiagnosticsConfig.ServiceName)).WithTracing(tracing =>{tracing.AddAspNetCoreInstrumentation().AddHttpClientInstrumentation().AddSource("Yarp.ReverseProxy");tracing.AddOtlpExporter();});builder.Services.AddAuthorization();
builder.Services.AddAuthentication().AddJwtBearer();
builder.Services.ConfigureOptions<JwtBearerConfigureOptions>();
WebApplication app = builder.Build();
app.UseLogContextTraceLogging();
app.UseSerilogRequestLogging();
app.UseAuthentication();
app.UseAuthorization();
app.MapReverseProxy();
app.Run();

3. 添加jwt配置

namespace Evently.Gateway.Authentication;
internal sealed class JwtBearerConfigureOptions(IConfiguration configuration): IConfigureNamedOptions<JwtBearerOptions>
{private const string ConfigurationSectionName = "Authentication";public void Configure(JwtBearerOptions options){configuration.GetSection(ConfigurationSectionName).Bind(options);}public void Configure(string? name, JwtBearerOptions options){Configure(options);}
}

4. 添加日志追踪

  1. 添加日志追踪
using System.Diagnostics;
using Serilog.Context;
namespace Evently.Gateway.Middleware;
internal sealed class LogContextTraceLoggingMiddleware(RequestDelegate next)
{public Task Invoke(HttpContext context){string traceId = Activity.Current?.TraceId.ToString();using (LogContext.PushProperty("TraceId", traceId)){return next.Invoke(context);}}
}
  1. 注册
namespace Evently.Gateway.Middleware;
internal static class MiddlewareExtensions
{internal static IApplicationBuilder UseLogContextTraceLogging(this IApplicationBuilder app){app.UseMiddleware<LogContextTraceLoggingMiddleware>();return app;}
}

5. 配置appsettings

  • 基础设置
{"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},"Serilog": {"Using": ["Serilog.Sinks.Console","Serilog.Sinks.Seq"],"MinimumLevel": {"Default": "Information","Override": {"Microsoft": "Information"}},"WriteTo": [{ "Name": "Console" },{"Name": "Seq","Args": { "serverUrl": "http://evently.seq:5341" }}],"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],"Properties": {"Application": "Evently.Gateway"}},"OTEL_EXPORTER_OTLP_ENDPOINT": "http://evently.jaeger:4317",
}

6. Yarp反向代理设置

在这里插入图片描述

http://www.dtcms.com/wzjs/500593.html

相关文章:

  • 开家网站建设培训学校项目推广平台有哪些
  • erp软件前十名seo网站优化培训多少价格
  • 郑州做网站的联系方式网络营销与策划试题及答案
  • 苹果cms影视源码武汉抖音seo搜索
  • 昌平做网站公司搜索引擎营销的英文缩写
  • 永久建站空间购买网络推广是什么专业
  • 黄石网站建设公司盐城seo排名
  • 做效果图比较好的模型网站有哪些营销推广策划方案
  • 接做施工图的网站免费推广方式都有哪些
  • 广东平台网站建设制作正规推广赚佣金的平台
  • thinkphp制作网站开发成都网站推广公司
  • 哪些网站是做色选机销售的网络营销的功能有哪些?
  • wordpress怎么恢复自带主题seo基础知识
  • 做淘宝网站用什么软件做湖南网络优化
  • 做母婴的网站有哪些北京seo设计公司
  • 淘宝上做网站建设靠谱吗百度官方网平台
  • 重庆企业网站制作公司线上平台推广方式
  • 学习建设网站滕州今日头条新闻
  • 专业做汽车网站优化排名数据查询网站
  • 沈阳企业建站系统模板兰州seo培训
  • 企业服务类网站百度怎么转人工客服
  • 网站备案 主体黑名单小红书kol推广
  • 设计感强的网站网站查询平台官网
  • 网站建设 技术 哪些内容seo综合排名优化
  • 网站的前台和后台网站如何进行网络推广
  • 企业网站建设变相收取等级保护费网页制作免费网站制作
  • 网站怎么做百度快照西安网站制作建设
  • 百度网址名称是什么搜狗搜索引擎优化指南
  • 东营市东营网站设计互联网医疗的营销策略
  • 专做正品 网站网站推广优化排名seo