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

Asp .Net Core 系列:集成 Ocelot+Consul实现网关、服务注册、服务发现

什么是Ocelot?

Ocelot是一个开源的ASP.NET Core微服务网关,它提供了API网关所需的所有功能,如路由、认证、限流、监控等。

Ocelot是一个简单、灵活且功能强大的API网关,它可以与现有的服务集成,并帮助您保护、监控和扩展您的微服务。

以下是Ocelot的一些主要功能:

  1. 路由管理:Ocelot允许您定义路由规则,将请求路由到正确的微服务。
  2. 认证和授权:Ocelot支持多种认证机制,如JWT、OAuth等,并允许您定义访问控制策略,确保只有授权的用户才能访问特定的API。
  3. 限流和速率限制:Ocelot提供了一些内置的限流和速率限制功能,以确保您的服务不会受到过度的请求压力。
  4. 监控和日志:Ocelot可以收集和显示各种度量指标,帮助您了解您的服务的性能和行为。此外,它还可以将日志记录到各种日志源,以便您进行分析和故障排除。
  5. 集成:Ocelot可以与现有的服务集成,包括Kubernetes、Consul等。
  6. 易于扩展:Ocelot的设计使其易于扩展,您可以编写自己的中间件来处理特定的逻辑,例如修改请求或响应、添加自定义的认证机制等。
  7. 可扩展的配置:Ocelot使用JSON配置文件进行配置,这意味着您可以轻松地根据需要进行配置更改,而无需重新编译代码。

总之,Ocelot是一个功能强大且易于使用的API网关,可以帮助您保护、监控和扩展您的微服务。

Asp .Net Core 集成 Ocelot

要在ASP.NET Core中集成Ocelot,您可以按照以下步骤进行操作:

  1. 安装Ocelot NuGet包:
    在您的ASP.NET Core项目中,打开终端或NuGet包管理器控制台,并运行以下命令来安装Ocelot的NuGet包:
dotnet add package Ocelot
  1. 添加Ocelot配置文件:
{  "Routes": [ //这里注意一下版本(旧版本用ReRoutes){"DownstreamPathTemplate": "/api/{controller}", //下游路径模板"DownstreamScheme": "http", //下游方案//"DownstreamHostAndPorts": [//  {//    "Host": "localhost",//    "Port": "5014"//  }//], //下游主机和端口"UpstreamPathTemplate": "/api/product/{controller}", //上游路径模板"UpstreamHttpMethod": [], //上游请求方法,可以设置特定的 HTTP 方法列表或设置空列表以允许其中任何方法"ServiceName": "api-product-service", //请求服务名称"LoadBalancerOptions": {"Type": "LeastConnection" //负载均衡算法:目前 Ocelot 有RoundRobin 和LeastConnection算法}}],"GlobalConfiguration": {"BaseUrl": "http://localhost:5015", //进行标头查找和替换以及某些管理配置"ServiceDiscoveryProvider": {"Scheme": "http","Host": "127.0.0.1", //你的Consul的ip地址"Port": 8500, //你的Consul的端口"Type": "Consul" //类型//"ConfigurationKey": "Consul" //指定配置键,键入您的配置}}
}
  1. 配置Ocelot服务:
builder.Services.AddOcelot();

Configure方法中配置请求管道并添加Ocelot中间件:

app.UseOcelot().Wait();

Ocelot 集成 Consul

要将Ocelot集成到Consul中,您可以按照以下步骤进行操作:

  1. 安装依赖项:
    在您的ASP.NET Core项目中,安装Ocelot和Consul的NuGet包。您可以使用以下命令来安装这些包:
dotnet add package Ocelot.Provider.Consul
  1. 配置Ocelot:
    在Ocelot的配置中,您需要指定Consul作为服务发现和配置的提供者。在Ocelot的配置文件(例如appsettings.json)中,添加以下内容:
{  "GlobalConfiguration": {"BaseUrl": "http://localhost:5015", //进行标头查找和替换以及某些管理配置"ServiceDiscoveryProvider": {"Scheme": "http","Host": "127.0.0.1", //你的Consul的ip地址"Port": 8500, //你的Consul的端口"Type": "Consul" //类型//"ConfigurationKey": "Consul" //指定配置键,键入您的配置}} 
}

确保将ConsulHostConsulPort设置为Consul服务器的正确地址和端口。

  1. 启动Ocelot:
    在您的ASP.NET Core应用程序中启动Ocelot。您可以在Startup.cs文件中添加以下代码:
builder.Services.AddOcelot().AddConsul(); 

全部代码

Consul相关代码

namespace MCode.Common.Extensions.Consul
{public class ConsulOptions{/// <summary>/// 当前应用IP/// </summary>public string IP { get; set; }/// <summary>/// 当前应用端口/// </summary>public int Port { get; set; }/// <summary>/// 当前服务名称/// </summary>public string ServiceName { get; set; }/// <summary>/// Consul集群IP/// </summary>public string ConsulIP { get; set; }/// <summary>/// Consul集群端口/// </summary>public int ConsulPort { get; set; }/// <summary>/// 权重/// </summary>public int? Weight { get; set; }}
}
using Consul.AspNetCore;
using Consul;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.AspNetCore.Builder;namespace MCode.Common.Extensions.Consul
{public static class ConsulServiceExtensions{/// <summary>/// 向容器中添加Consul必要的依赖注入/// </summary>/// <param name="services"></param>/// <param name="configuration"></param>/// <returns></returns>public static IServiceCollection AddMCodeConsul(this IServiceCollection services){var configuration = services.BuildServiceProvider().GetRequiredService<IConfiguration>();// 配置consul服务注册信息var consulOptions = configuration.GetSection("Consul").Get<ConsulOptions>();// 通过consul提供的注入方式注册consulClientservices.AddConsul(options => options.Address = new Uri($"http://{consulOptions.ConsulIP}:{consulOptions.ConsulPort}"));// 通过consul提供的注入方式进行服务注册var httpCheck = new AgentServiceCheck(){DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(5),//服务启动多久后注册Interval = TimeSpan.FromSeconds(10),//健康检查时间间隔,或者称为心跳间隔HTTP = $"http://{consulOptions.IP}:{consulOptions.Port}/health",//健康检查地址Timeout = TimeSpan.FromSeconds(10)};// Register service with consulservices.AddConsulServiceRegistration(options =>{options.Checks = new[] { httpCheck };options.ID = Guid.NewGuid().ToString();options.Name = consulOptions.ServiceName;options.Address = consulOptions.IP;options.Port = consulOptions.Port;options.Meta = new Dictionary<string, string>() { { "Weight", consulOptions.Weight.HasValue ? consulOptions.Weight.Value.ToString() : "1" } };options.Tags = new[] { $"urlprefix-/{consulOptions.ServiceName}" }; //添加});return services;}/// <summary>/// 配置Consul检查服务/// </summary>/// <param name="app"></param>/// <returns></returns>public static IApplicationBuilder UseConsulCheckService(this IApplicationBuilder app){app.Map("/health", app =>{app.Run(async context =>{await Task.Run(() => context.Response.StatusCode = 200);});});return app;}}
}

Cors

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace MCode.Common.Extensions.Cors
{public static class CorsServiceExtensions{private readonly static string PolicyName = "MCodeCors";/// <summary>/// 添加跨域/// </summary>/// <param name="services">服务集合</param>/// <returns></returns>public static IServiceCollection AddMCodeCors(this IServiceCollection services){if (services == null) throw new ArgumentNullException(nameof(services));//origin microsoft.aspnetcore.cors      return services.AddCors(options =>{options.AddPolicy(PolicyName, policy =>{policy.SetIsOriginAllowed(_ => true).AllowAnyMethod().AllowAnyHeader().AllowCredentials();});});}/// <summary>/// 使用跨域/// </summary>/// <param name="app">应用程序建造者</param>/// <returns></returns>public static IApplicationBuilder UseMCodeCors(this IApplicationBuilder app){return app.UseCors(PolicyName);}}
}

Swagger

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace MCode.Common.Extensions.Swagger
{/// <summary>/// 网关Swagger配置/// </summary>public class OcelotSwaggerOptions{public List<SwaggerEndPoint> SwaggerEndPoints { get; set; }}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace MCode.Common.Extensions.Swagger
{/// <summary>/// 网关Swagger配置/// </summary>public class OcelotSwaggerOptions{public List<SwaggerEndPoint> SwaggerEndPoints { get; set; }}
}
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace MCode.Common.Extensions.Swagger
{/// <summary>/// Swagger配置/// </summary>public class SwaggerOptions{/// <summary>/// 服务名称/// </summary>public string ServiceName { get; set; }/// <summary>/// API信息/// </summary>public OpenApiInfo ApiInfo { get; set; }/// <summary>/// Xml注释文件/// </summary>public string[] XmlCommentFiles { get; set; }/// <summary>/// 构造函数/// </summary>/// <param name="serviceName">服务名称</param>/// <param name="apiInfo">API信息</param>/// <param name="xmlCommentFiles">Xml注释文件</param>public SwaggerOptions(string serviceName, OpenApiInfo apiInfo, string[] xmlCommentFiles = null){ServiceName = !string.IsNullOrWhiteSpace(serviceName) ? serviceName : throw new ArgumentException("serviceName parameter not config.");ApiInfo = apiInfo;XmlCommentFiles = xmlCommentFiles;}}
}
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;namespace MCode.Common.Extensions.Swagger
{/// <summary>/// Swagger 服务扩展/// </summary>public static class SwaggerServiceExtensions{/// <summary>/// 添加 Swagger 服务/// </summary>/// <param name="services"></param>/// <param name="swaggerOptions"></param>/// <returns></returns>public static IServiceCollection AddMCodeSwagger(this IServiceCollection services, SwaggerOptions swaggerOptions){services.AddSingleton(swaggerOptions);SwaggerGenServiceCollectionExtensions.AddSwaggerGen(services, c =>{c.SwaggerDoc(swaggerOptions.ServiceName, swaggerOptions.ApiInfo);if (swaggerOptions.XmlCommentFiles != null){foreach (string xmlCommentFile in swaggerOptions.XmlCommentFiles){string str = Path.Combine(AppContext.BaseDirectory, xmlCommentFile);if (File.Exists(str)) c.IncludeXmlComments(str, true);}}SwaggerGenOptionsExtensions.CustomSchemaIds(c, x => x.FullName);c.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme{Type = SecuritySchemeType.Http,Scheme = "bearer",BearerFormat = "JWT",Description = "请输入 bearer 认证"});c.AddSecurityRequirement(new OpenApiSecurityRequirement{{new OpenApiSecurityScheme{Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "bearerAuth" }},new string[] {}}});});return services;}/// <summary>/// 使用 Swagger UI/// </summary>/// <param name="app"></param>/// <returns></returns>public static IApplicationBuilder UseMCodeSwagger(this IApplicationBuilder app){string serviceName = app.ApplicationServices.GetRequiredService<SwaggerOptions>().ServiceName;SwaggerUIBuilderExtensions.UseSwaggerUI(SwaggerBuilderExtensions.UseSwagger(app), c =>{c.SwaggerEndpoint("/swagger/" + serviceName + "/swagger.json", serviceName);});return app;}public static IServiceCollection AddMCodeOcelotSwagger(this IServiceCollection services, OcelotSwaggerOptions ocelotSwaggerOptions){services.AddSingleton(ocelotSwaggerOptions);SwaggerGenServiceCollectionExtensions.AddSwaggerGen(services);return services;}public static IApplicationBuilder UseMCodeOcelotSwagger(this IApplicationBuilder app){OcelotSwaggerOptions ocelotSwaggerOptions = app.ApplicationServices.GetService<OcelotSwaggerOptions>();if (ocelotSwaggerOptions == null || ocelotSwaggerOptions.SwaggerEndPoints == null){return app;}SwaggerUIBuilderExtensions.UseSwaggerUI(SwaggerBuilderExtensions.UseSwagger(app), c =>{foreach (SwaggerEndPoint swaggerEndPoint in ocelotSwaggerOptions.SwaggerEndPoints){c.SwaggerEndpoint(swaggerEndPoint.Url, swaggerEndPoint.Name);}});return app;}}
}

MCode.ApiGateway.Program

using MCode.Common.Extensions.Swagger;
using MCode.Common.Extensions.Consul;
using MCode.Common.Extensions.Cors;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Provider.Consul;
using Microsoft.AspNetCore.Hosting;var builder = WebApplication.CreateBuilder(args);builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("Url") ?? "");//builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("ocelot.json", false, true);// Add services to the container.
builder.Services.AddMCodeConsul();builder.Services.AddMCodeCors();builder.Services.AddMCodeOcelotSwagger(new OcelotSwaggerOptions { SwaggerEndPoints = new List<SwaggerEndPoint> { new SwaggerEndPoint { Name = "api-product-service", Url= "http://localhost:5014/swagger/api-product-service/swagger.json" } } });builder.Services.AddOcelot().AddConsul();builder.Services.AddControllers();var app = builder.Build();app.UseMCodeCors();app.UseMCodeOcelotSwagger();app.UseConsulCheckService();// Configure the HTTP request pipeline.app.UseAuthorization();app.UseOcelot().Wait();app.Run();

appsettings.json

{"Logging": {"LogLevel": {"Default": "Information","Microsoft.AspNetCore": "Warning"}},"Routes": [ //这里注意一下版本(旧版本用ReRoutes){"DownstreamPathTemplate": "/api/{controller}", //下游路径模板"DownstreamScheme": "http", //下游方案//"DownstreamHostAndPorts": [//  {//    "Host": "localhost",//    "Port": "5014"//  }//], //下游主机和端口"UpstreamPathTemplate": "/api/product/{controller}", //上游路径模板"UpstreamHttpMethod": [], //上游请求方法,可以设置特定的 HTTP 方法列表或设置空列表以允许其中任何方法"ServiceName": "api-product-service", //请求服务名称"LoadBalancerOptions": {"Type": "LeastConnection" //负载均衡算法:目前 Ocelot 有RoundRobin 和LeastConnection算法}}],"GlobalConfiguration": {"BaseUrl": "http://localhost:5015", //进行标头查找和替换以及某些管理配置"ServiceDiscoveryProvider": {"Scheme": "http","Host": "127.0.0.1", //你的Consul的ip地址"Port": 8500, //你的Consul的端口"Type": "Consul" //类型//"ConfigurationKey": "Consul" //指定配置键,键入您的配置}},"Url": "http://localhost:5015","Consul": {"ConsulIP": "127.0.0.1","ConsulPort": "8500","ServiceName": "api-gateway","Ip": "localhost","Port": "5015","Weight": 1},"AllowedHosts": "*"
}

MCode.Product.Api.Program

using MCode.Product.Api;
using MCode.Common.Extensions.Consul;
using MCode.Common.Extensions.Cors;
using MCode.Common.Extensions.Swagger;var builder = WebApplication.CreateBuilder(args);// Add services to the container.builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("Url") ?? "");builder.Services.AddControllers();builder.Services.AddMCodeConsul();builder.Services.AddMCodeCors();builder.Services.AddMCodeSwagger(new SwaggerOptions("api-product-service", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "产品服务" }, new string[] { "MCode.Product.Api.xml" }));var app = builder.Build();app.UseAuthorization();app.UseMCodeCors();app.UseMCodeSwagger();app.UseConsulCheckService();app.MapControllers();app.Run();

appsettings.json

{"Logging": {"LogLevel": {"Default": "Information","Microsoft.AspNetCore": "Warning"}},"AllowedHosts": "*","Url": "http://localhost:5014","Consul": {"ConsulIP": "127.0.0.1","ConsulPort": "8500","ServiceName": "api-product-service","Ip": "localhost","Port": "5014","Weight": 1}
}

效果

image

image

相关文章:

Asp .Net Core 系列:集成 Ocelot+Consul实现网关、服务注册、服务发现

什么是Ocelot? Ocelot是一个开源的ASP.NET Core微服务网关&#xff0c;它提供了API网关所需的所有功能&#xff0c;如路由、认证、限流、监控等。 Ocelot是一个简单、灵活且功能强大的API网关&#xff0c;它可以与现有的服务集成&#xff0c;并帮助您保护、监控和扩展您的微…...

MSSQL行转列、列转行

行转列 SELECT * FROM student PIVOT ( SUM(score) FOR subject IN (语文, 数学, 英语) ) AS PivotedData; 列转行 SELECT * FROM student1 UNPIVOT ( score FOR subject IN ("语文","数学","英语") )AS PivotedData;...

【MySQL】创建和管理表

文章目录 前置 标识符命名规则一、MySQL数据类型二、创建和管理数据库2.1 创建数据库2.2 使用数据库2.3 修改数据库2.4 删除数据库 三、创建表3.1 创建方式一3.2 创建方式二3.3 查看数据表结构 四、修改表4.1 增加一个列4.2 修改一个列4.3 重命名一个列4.4 删除一个列 五、重命…...

缓存和数据库一致性

前言&#xff1a; 项目的难点是如何保证缓存和数据库的一致性。无论我们是先更新数据库&#xff0c;后更新缓存还是先更新数据库&#xff0c;然后删除缓存&#xff0c;在并发场景之下&#xff0c;仍然会存在数据不一致的情况&#xff08;也存在删除失败的情况&#xff0c;删除…...

iOS UI掉帧和卡顿优化解决方案记录

UI卡顿原理 在 VSync 信号到来后&#xff0c;系统图形服务会通过 CADisplayLink 等机制通知 App&#xff0c;App 主线程开始在 CPU 中计算显示内容&#xff0c;比如视图的创建、布局计算、图片解码、文本绘制等。随后 CPU 会将计算好的内容提交到 GPU 去&#xff0c;由 GPU 进行…...

transbigdata 笔记: 轨迹密集化/稀疏化 轨迹平滑

1 密集化 transbigdata.traj_densify(data, col[Vehicleid, Time, Lng, Lat], timegap15) 轨迹致密化&#xff0c;保证至多每隔timegap秒都有一个轨迹点 这边插补使用的是pandas的interpolate&#xff0c;method设置的是index 1.1 举例 transbigdata 笔记&#xff1a; 官方…...

反向代理的本质是什么?

反向代理是一种网络架构模式&#xff0c;通常用于提供静态内容、处理安全、负载均衡和缓存等任务。在这种架构中&#xff0c;客户端发送的请求首先到达反向代理服务器&#xff0c;然后由反向代理服务器将请求转发给后端的实际服务器。反向代理服务器可以处理和修改请求和响应&a…...

Kali Linux保姆级教程|零基础从入门到精通,看完这一篇就够了!(附工具包)

作为一名从事网络安全的技术人员&#xff0c;不懂Kali Linux的话&#xff0c;连脚本小子都算不上。 Kali Linux预装了数百种享誉盛名的渗透工具&#xff0c;使你可以更轻松地测试、破解以及进行与数字取证相关的任何其他工作。 今天给大家分享一套Kali Linux资料合集&#xf…...

UML-用例图

提示&#xff1a;用例图是软件建模的开始&#xff0c;软件建模中的其他图形都将以用例图为依据。用例图列举了系统所需要实现的所有功能&#xff0c;除了用于软件开发的需求分析阶段&#xff0c;也可用于软件的系统测试阶段。 UML-用例图 一、用例图的基础知识1.用例图的构成元…...

jmeter--8.加密传输

目录 1. Base64加密 2. MD5加密 3. SHA加密&#xff08;sha1\sha\sha224\sha256\sha384\sha512&#xff09; 4. RSA加密-公钥加密&#xff0c;私钥解密 1. Base64加密 1.1 在需要加密传输的接口下新增BeanShell 预处理程序&#xff0c;${username}可替换成value值&#xff…...

微信小程序canvas画布转图片转pdf文件

关键步骤介绍 步骤一:将canvas页面保存为图片 for(var a=0;a<this.data.page_canvas.length;++a){ var t_page_img = await this.canvas_to_image(this.data.page_canvas[a]) t_img.push(t_page_img) } this.data.page_canvas是保存的canvas界面,this.c…...

【Linux操作】国产Linux服务管理操作

【Linux操作】国产Linux服务管理操作 前言SAMBA配置服务器端1. 安装相关包2. 配置/etc/samba/smb.conf&#xff0c;在此文件末尾添加如下内容&#xff0c;并保存退出。3. 创建/home/share并更改权限4. 启动samba服务 客户端• Windows客户端• 麒麟客户端 Telnet1、telnet语法2…...

大语言模型系列-word2vec

文章目录 前言一、word2vec的网络结构和流程1.Skip-Gram模型2.CBOW模型 二、word2vec的训练机制1. Hierarchical softmax2. Negative Sampling 总结 前言 在前文大语言模型系列-总述已经提到传统NLP的一般流程&#xff1a; 创建语料库 > 数据预处理 > 分词向量化 > …...

vue项目运行报错this[kHandle] = new _Hash(algorithm, xofLen)

自从昨天分盘重装了最新版本的Node之后&#xff0c;项目是一启一个报错 出现这个报错时&#xff0c;需要在package.json文件中 dev命令行 增加&#xff1a;set NODE_OPTIONS–openssl-legacy-provider 出现该问题的原因&#xff1a; node.js V17开始版本中发布的是OpenSSL3.0,…...

APP兼容性测试,这几个面试硬技能,包教包会

兼容性测试主要通过人工或自动化的方式&#xff0c;在需要覆盖的终端设备上进行功能用例执行&#xff0c;查看软件性能、稳定性等是否正常。 对于需要覆盖的终端设备&#xff0c;大型互联网公司&#xff0c;像 BAT&#xff0c;基本都有自己的测试实验室&#xff0c;拥有大量终…...

【学习iOS高质量开发】——熟悉Objective-C

文章目录 一、Objective-C的起源1.OC和其它面向对象语言2.OC和C语言3.要点 二、在类的头文件中尽量少引用其他头文件1.OC的文件2.向前声明的好处3.如何正确引入头文件4.要点 三、多用字面量语法&#xff0c;少用与之等价的方法1.何为字面量语法2.字面数值3.字面量数组4.字面量字…...

Qt/QML编程之路:Grid、GridLayout、GridView、Repeater(33)

GRID网格用处非常大,不仅在excel中,在GUI中,也是非常重要的一种控件。 Grid 网格是一种以网格形式定位其子项的类型。网格创建一个足够大的单元格网格,以容纳其所有子项,并将这些项从左到右、从上到下放置在单元格中。每个项目都位于其单元格的左上角,位置为(0,0)。…...

mac pro “RESP.app”意外退出 redis desktop manager

文章目录 redis desktop manager下载地址提示程序含有恶意代码“RESP.app”意外退出解决办法&#xff1a;下载python3.10.并安装重新打开RESP如果还是不行&#xff0c;那么需要替换错误路径&#xff08;我的没用&#xff09;外传 最近在研究redis的消息&#xff0c;看到了strea…...

VirtualBox 如何让虚拟机和主机互相通信

首先建立一张虚拟网卡 在这里进行网络设置 设置成固定ip,这张网卡专门用来通信&#xff0c;上面的网卡用来上网的...

【Java】源码文件开头添加注释

需求 应公司质量部要求&#xff0c;需要对代码做静态检查。质量部要求&#xff0c;源码文件必须在起始行起设置一些注释&#xff0c;然而项目已经开发了一年之久&#xff0c;且没有维护这个注释。 此时&#xff0c;面对好几千个源码文件&#xff0c;我们如何快速添加相应的注…...

接口测试中缓存处理策略

在接口测试中&#xff0c;缓存处理策略是一个关键环节&#xff0c;直接影响测试结果的准确性和可靠性。合理的缓存处理策略能够确保测试环境的一致性&#xff0c;避免因缓存数据导致的测试偏差。以下是接口测试中常见的缓存处理策略及其详细说明&#xff1a; 一、缓存处理的核…...

Xshell远程连接Kali(默认 | 私钥)Note版

前言:xshell远程连接&#xff0c;私钥连接和常规默认连接 任务一 开启ssh服务 service ssh status //查看ssh服务状态 service ssh start //开启ssh服务 update-rc.d ssh enable //开启自启动ssh服务 任务二 修改配置文件 vi /etc/ssh/ssh_config //第一…...

PPT|230页| 制造集团企业供应链端到端的数字化解决方案:从需求到结算的全链路业务闭环构建

制造业采购供应链管理是企业运营的核心环节&#xff0c;供应链协同管理在供应链上下游企业之间建立紧密的合作关系&#xff0c;通过信息共享、资源整合、业务协同等方式&#xff0c;实现供应链的全面管理和优化&#xff0c;提高供应链的效率和透明度&#xff0c;降低供应链的成…...

Docker 运行 Kafka 带 SASL 认证教程

Docker 运行 Kafka 带 SASL 认证教程 Docker 运行 Kafka 带 SASL 认证教程一、说明二、环境准备三、编写 Docker Compose 和 jaas文件docker-compose.yml代码说明&#xff1a;server_jaas.conf 四、启动服务五、验证服务六、连接kafka服务七、总结 Docker 运行 Kafka 带 SASL 认…...

Spring AI 入门:Java 开发者的生成式 AI 实践之路

一、Spring AI 简介 在人工智能技术快速迭代的今天&#xff0c;Spring AI 作为 Spring 生态系统的新生力量&#xff0c;正在成为 Java 开发者拥抱生成式 AI 的最佳选择。该框架通过模块化设计实现了与主流 AI 服务&#xff08;如 OpenAI、Anthropic&#xff09;的无缝对接&…...

在web-view 加载的本地及远程HTML中调用uniapp的API及网页和vue页面是如何通讯的?

uni-app 中 Web-view 与 Vue 页面的通讯机制详解 一、Web-view 简介 Web-view 是 uni-app 提供的一个重要组件&#xff0c;用于在原生应用中加载 HTML 页面&#xff1a; 支持加载本地 HTML 文件支持加载远程 HTML 页面实现 Web 与原生的双向通讯可用于嵌入第三方网页或 H5 应…...

SQL慢可能是触发了ring buffer

简介 最近在进行 postgresql 性能排查的时候,发现 PG 在某一个时间并行执行的 SQL 变得特别慢。最后通过监控监观察到并行发起得时间 buffers_alloc 就急速上升,且低水位伴随在整个慢 SQL,一直是 buferIO 的等待事件,此时也没有其他会话的争抢。SQL 虽然不是高效 SQL ,但…...

解析奥地利 XARION激光超声检测系统:无膜光学麦克风 + 无耦合剂的技术协同优势及多元应用

在工业制造领域&#xff0c;无损检测&#xff08;NDT)的精度与效率直接影响产品质量与生产安全。奥地利 XARION开发的激光超声精密检测系统&#xff0c;以非接触式光学麦克风技术为核心&#xff0c;打破传统检测瓶颈&#xff0c;为半导体、航空航天、汽车制造等行业提供了高灵敏…...

Vue 模板语句的数据来源

&#x1f9e9; Vue 模板语句的数据来源&#xff1a;全方位解析 Vue 模板&#xff08;<template> 部分&#xff09;中的表达式、指令绑定&#xff08;如 v-bind, v-on&#xff09;和插值&#xff08;{{ }}&#xff09;都在一个特定的作用域内求值。这个作用域由当前 组件…...

9-Oracle 23 ai Vector Search 特性 知识准备

很多小伙伴是不是参加了 免费认证课程&#xff08;限时至2025/5/15&#xff09; Oracle AI Vector Search 1Z0-184-25考试&#xff0c;都顺利拿到certified了没。 各行各业的AI 大模型的到来&#xff0c;传统的数据库中的SQL还能不能打&#xff0c;结构化和非结构的话数据如何和…...