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

使用 API Gateway Integrator 在 Quarkus 中实施适用于 AWS Lambda 的 OpenAPI

AWS API Gateway 集成使得使用符合 OpenAPI 标准的 Lambda Function 轻松实现 REST API。

关于开放API

        它是一个 允许以标准方式描述 REST API 的规范。 OpenAPI规范 (OAS) 为 REST API 定义了与编程语言无关的标准接口描述。这使得人类和计算机都可以发现和理解服务的功能,而无需访问源代码、附加文档或检查网络流量。

关于Swagger

        Swagger是一组围绕 OpenAPI 规范构建的开源工具,可以帮助软件专业人员设计、构建、记录和使用 REST API。OpenAPI 处理规范,Swagger 实现规范来描述 REST API 。

OpenAPI规范简介

目的

  • API是使用OpenAPI标准定义的,可以被人类和计算机发现,无需访问源代码、文档或通过网络流量检查即可了解服务的功能。 
  • 如果定义正确,消费者可以使用最少量的实现逻辑来理解远程服务并与之交互。
  • 然后,文档生成工具可以使用 OpenAPI 定义来显示 API,代码生成工具可以使用各种编程语言、测试工具和许多其他用例来生成服务器和客户端。

开放API的主要 概念

OpenAPI文档

定义/描述 API 的文档(或一组文档)。OpenAPI 定义使用并符合 OpenAPI 规范。 

路径模板

路径模板是指使用由大括号 ({}) 分隔的模板表达式,将 URL 路径的一部分标记为可使用路径参数进行替换。

路径中的每个模板表达式必须对应于路径项本身和/或路径项的每个操作中包含的路径参数。

媒体类型

媒体类型定义分布在多个资源中。媒体类型定义应符合RFC6838。

可能的媒体类型定义的一些示例:

  • 应用程序/json
  • 测试/普通;chartset-uff-8

HTTP 状态代码

HTTP 状态代码用于指示已执行操作的状态。可用的状态代码由RFC7231定义,注册的状态代码列在IANA 状态代码注册表中。

AWS Lambda 函数的开放 API 参考实现 

参考架构

 

参考实现由以下组件组成:

  • AWS Lambda函数实现业务需求/逻辑 
  • API 网关将功能公开为 API
  • Amazon API 网关集成器,用于集成开放 API 规范并将 Lambda 函数操作公开为 API

有关每个架构组件的更多详细信息,请参阅后续部分。

关于 AWS Lambda 函数

Lambda 是一种计算服务,允许在不配置或管理服务器的情况下运行代码。Lambda 在高可用性计算基础设施上运行代码,并执行计算资源的所有管理,包括服务器和操作系统维护、容量配置和自动扩展以及日志记录。使用 Lambda,几乎可以为任何类型的应用程序或后端服务运行代码。它所需要的只是以Lambda 支持的语言之一提供代码。
Lambda 仅在需要时运行函数并自动扩展,从每天几个请求到每秒数千个请求。它节省了计算成本,因为只需支付函数在运行时消耗的计算时间——代码不运行时不收费。可以使用 Lambda API 或来自其他 AWS 服务的事件调用 lambda 函数,例如在 S3 存储桶中创建对象时。

关于 AWS API 网关 

Amazon API Gateway 是一项完全托管的服务,使开发人员可以轻松创建、发布、维护、监控和保护任何规模的 API。API 充当应用程序从后端服务访问数据、业务逻辑或功能的“前门”。

关于AWS API集成功能

这种类型的集成允许 API 公开 AWS 服务操作。在AWS集成中,需要配置集成请求和集成响应,并设置从方法请求到集成请求、从集成响应到方法响应的必要数据映射。

它允许指定用于此方法的后端集成的详细信息。此扩展是OpenAPI 操作对象的扩展属性。结果是一个API 网关集成对象。

重要财产

与指定后​​端的集成类型。有效值为:

  • http 或 http_proxy,用于与 HTTP 后端集成。
  • aws_proxy,用于与 AWS Lambda 函数的代理集成 
  • aws,用于与 AWS Lambda 函数自定义集成,或与其他 AWS 服务集成,例如 Amazon DynamoDB、Amazon Simple notification Service 或 Amazon Simple Queue Service。
  • mock,用于与 API Gateway 集成,无需调用任何后端。这种类型的集成允许 API Gateway 返回响应,而无需将请求进一步发送到后端。

Lambda 代理集成支持单个 Lambda 函数的简化集成设置。设置很简单,可以随后端一起发展,而无需拆除已经创建的设置。由于这些原因,强烈建议与 Lambda 函数集成。

相比之下,Lambda 自定义集成允许为具有类似输入和输出数据格式要求的各种集成端点重用已配置的映射模板。该设置涉及较多,推荐用于更高级的应用场景。

x-amazon-apigateway-integrations例子

以下示例使用 OpenAPI 标准定义 HTTP API(一个 GET 和一个 POST),并为每个 API 使用一个 API 网关集成来与 Lambda Function 集成(通过引用函数的 ARN)。它使用 AWS Identity and Access Management (IAM) 角色作为集成凭证。以下格式采用 YAML。 

openapi: 3.0.1
info:description: "This is a definition of Proxy Pattern Service. The service has 2 APIs."version: v1title: "Proxy Pattern Service"
paths:/v1/proxypattern/employee:options:summary: CORS supportdescription: |Enable CORS by returning correct headersconsumes:- application/jsonproduces:- application/jsontags:- CORSsecurity:- NONE: []x-amazon-apigateway-integration:type: mockrequestTemplates:application/json: |{"statusCode" : 200}responses:"default":statusCode: "200"responseParameters:method.response.header.Access-Control-Allow-Headers : "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,x-apigw-api-id,X-Amz-Security-Token,Cache-Control'"method.response.header.Access-Control-Allow-Methods : "'*'"method.response.header.Access-Control-Allow-Origin : "'*'"responseTemplates:application/json: |{}responses:200:description: Default response for CORS methodheaders:Access-Control-Allow-Headers:type: "string"Access-Control-Allow-Methods:type: "string"Access-Control-Allow-Origin:type: "string"post:summary: "Save Employee"operationId: "saveemployees"tags:- saveemployeesrequestBody:required: truecontent:application/json:schema:$ref: '#/components/schemas/employee'responses:'200':description: "Saved Employee Successfully"headers:Access-Control-Allow-Origin:schema:type: "string"content:application/json:schema:$ref: "#/components/schemas/employee"'400':description: "Application Errors"headers:Access-Control-Allow-Origin:schema:type: "string"content:application/json:schema:$ref: '#/components/schemas/ErrorResponse''500':description: "Other unspecified Errors"headers:Access-Control-Allow-Origin:schema:type: "string"content:application/json:schema:$ref: '#/components/schemas/ErrorResponse'x-amazon-apigateway-integration:credentials:Fn::Sub: arn:aws:iam::${AWS::AccountId}:role/delegate-admin-lambda-proxy-pattern-rolehttpMethod: "POST"uri:Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ProxyPatternService.Arn}:live/invocationsresponses:"default":statusCode: "200"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'""BAD.*":statusCode: "400"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'""INT.*":statusCode: "500"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'"type: "aws_proxy"get:summary: "Get All the Employees"operationId: "getemployees"tags:- getemployeesresponses:'200':description: "All The Employees retrieved successfully"headers:Access-Control-Allow-Origin:schema:type: "string"content:application/json:schema:type: "array"items:$ref: "#/components/schemas/employee"'204':description: "Employees not found"headers:Access-Control-Allow-Origin:schema:type: "string"'500':description: "Other unspecified Errors"headers:Access-Control-Allow-Origin:schema:type: "string"content:application/json:schema:$ref: '#/components/schemas/ErrorResponse'x-amazon-apigateway-integration:credentials:Fn::Sub: arn:aws:iam::${AWS::AccountId}:role/delegate-admin-lambda-proxy-pattern-rolehttpMethod: "POST"uri:Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ProxyPatternService.Arn}:live/invocationsresponses:"default":statusCode: "200"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'""BAD.*":statusCode: "204"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'""INT.*":statusCode: "500"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'"type: "aws_proxy"components:schemas:Employee:type: objectdescription: EMPLOYEEproperties:employeeId:type: stringdescription: Id of the EmployeeemployeeName:type: stringdescription: Name of the Employeerequired:- employeeIdErrorResponse:type: "object"properties:errorCode:type: stringdescription: |indicates an error in processing.XXXX - Error in saving messageerrorMessage:type: stringdescription: "message description of error."

以下是 AWS Lambda 函数的云形成模板,该模板将通过 AWS API Gateway 公开。格式为 YAML。此处,已引用OpenAPI定义/openapi-apigateway-PxyPtrnSvc.yaml文件 ( ),以便API Gateway了解通过 OpenAPI 定义文件定义的集成点。

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS Serverless Quarkus HTTP - Proxy Pattern Poc Service
Globals:Api:EndpointConfiguration:Type: PRIVATEAuth:ResourcePolicy:CustomStatements: {Effect: 'Allow',Action: 'execute-api:Invoke',Resource: ['execute-api:/*/*/*'],Principal: '*'}
Resources:ProxyPatternServiceAWSApiGateway:Type: AWS::Serverless::ApiProperties:TracingEnabled: trueName: ProxyPatternServiceSvcApiGatewayStageName: devDefinitionBody:'Fn::Transform':Name: 'AWS::Include'Parameters:Location: './openapi-apigateway-PxyPtrnSvc.yaml'ProxyPatternServiceLogGroup:Type: AWS::Logs::LogGroupProperties:LogGroupName: '/aws/lambda/ProxyPatternService'RetentionInDays: 30ProxyPatternService:Type: AWS::Serverless::FunctionProperties:Handler: not.used.in.provided.runtimeRuntime: providedCodeUri: component1/function.zipMemorySize: 512Timeout: 900FunctionName: ProxyPatternServiceEnvironment:Variables:LOG_LEVEL: INFODISABLE_SIGNAL_HANDLERS: trueRole: !Sub "arn:aws:iam::${AWS::AccountId}:role/delegate-admin-lambda-proxy-pattern-role"Tracing: Active
Outputs:ProxyPatternServiceAWSApiGateway:Description: 'API Gateway endpoint URL for dev stage for Proxy Pattern Service Template'Value: !Sub 'https://${ProxyPatternServiceAWSApiGateway}.execute-api.${AWS::Region}.amazonaws.com/dev/'ProxyPatternServiceAWSApiGatewayRestApiId:Description: 'API Gateway ARN for Basic AWS API Gateway'Value: !Ref ProxyPatternServiceAWSApiGatewayExport:Name: ProxyPatternServiceAWSApiGateway-RestApiIdProxyPatternServiceAWSApiGatewayRootResourceId:Value: !GetAtt ProxyPatternServiceAWSApiGateway.RootResourceIdExport:Name: ProxyPatternServiceAWSApiGateway-RootResourceId

示例 API 定义可以与以下使用 Java 的 Controller 接口相关,并且可以在 Java Quarkus 中实现:

package com.example.proxypattern.controller;import com.example.proxypattern.exception.model.ErrorResponse;
import com.example.proxypattern.model.Employee;import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;@Path("v1/proxypattern/")
public interface IProxyPatternController {@GET@Path("/employee")@Produces(MediaType.APPLICATION_JSON)@Operation(summary = "Get All the Employees", description = "getEmployees")@APIResponses(value = {@APIResponse(responseCode = "204", description = "Employees not found"),@APIResponse(responseCode = "200", description = "All The Employees retrieved successfully", content = @Content(schema = @Schema(implementation = Employee.class))),@APIResponse(responseCode = "500", description = "Other unspecified Errors", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })public Response getAllEmployee();@POST@Path("/employee")@Consumes(MediaType.APPLICATION_JSON)@Produces(MediaType.APPLICATION_JSON)@Operation(summary = "Save Employee", description = "saveEmployees")@APIResponses(value = {@APIResponse(responseCode = "400", description = "Application Errors", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),@APIResponse(responseCode = "200", description = "Saved Employee Successfully", content = @Content(schema = @Schema(implementation = Employee.class))),@APIResponse(responseCode = "500", description = "Other unspecified Errors", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })public Response saveEmployee(Employee employee);
}

实现语言可能有所不同。如果技术决策是使用Java作为编码语言,则可以选择Java Quarkus作为Lambda函数的实现语言。Lambda 支持自定义运行时,因此可以本地构建 Quarkus 代码来解决与 Lambda 冷启动相关的响应时间问题。

控制器实现代码如下所示。这里,业务逻辑已通过业务服务类进行抽象:

package com.example.proxypattern.controller.impl;import com.example.proxypattern.controller.IProxyPatternController;
import com.example.proxypattern.model.Employee;
import com.example.proxypattern.service.impl.EmployeeServiceImpl;import lombok.extern.slf4j.Slf4j;
import org.eclipse.microprofile.opentracing.Traced;import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.core.Response;import java.util.List;@Slf4j
@Traced
@Singleton
public class ProxyPatternControllerImpl implements IProxyPatternController {@InjectEmployeeServiceImpl employeeService;@Overridepublic Response getAllEmployee() {Response.Status status = Response.Status.OK;//The business logic is abstracted here in Service codeList<Employee> listOfEmployee = employeeService.getAllEmployee();if(listOfEmployee.isEmpty()){status = Response.Status.NO_CONTENT;}log.info("Sending employee {}", listOfEmployee);return Response.status(status).entity(listOfEmployee).build();}@Overridepublic Response saveEmployee(Employee employee) {//The business logic is abstracted here in Service codeEmployee employeeResponse = employeeService.saveEmployee(employee);return Response.status(Response.Status.CREATED).entity(employeeResponse).build();}
}

可以使用Maven来构建项目,也可以使用以下依赖来构建项目:


<dependencies><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-resteasy</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-amazon-lambda-rest</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-smallrye-openapi</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-resteasy-jackson</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-logging-json</artifactId></dependency><dependency><groupId>org.jboss.slf4j</groupId><artifactId>slf4j-jboss-logmanager</artifactId></dependency><dependency><groupId>commons-logging</groupId><artifactId>commons-logging</artifactId><version>1.2</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-annotations</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-hibernate-validator</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-smallrye-opentracing</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-smallrye-health</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-junit5</artifactId><scope>test</scope></dependency><dependency><groupId>io.rest-assured</groupId><artifactId>rest-assured</artifactId><scope>test</scope></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-junit5-mockito</artifactId><scope>test</scope></dependency><dependency><groupId>org.jacoco</groupId><artifactId>org.jacoco.agent</artifactId><classifier>runtime</classifier><scope>test</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.20</version><scope>provided</scope></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId></dependency></dependencies>

结论

AWS API Gateway 集成可以轻松使用 Lambda Function 实现 REST API,该函数符合 OpenAPI 标准,并且可以轻松与 AWS API Gateway 集成。

相关文章:

使用 API Gateway Integrator 在 Quarkus 中实施适用于 AWS Lambda 的 OpenAPI

AWS API Gateway 集成使得使用符合 OpenAPI 标准的 Lambda Function 轻松实现 REST API。 关于开放API 它是一个 允许以标准方式描述 REST API 的规范。 OpenAPI规范 (OAS) 为 REST API 定义了与编程语言无关的标准接口描述。这使得人类和计算机都可以发现和理解服务的功能&am…...

【JVM】JVM中的分代回收

文章目录 分代收集算法什么是分代分代收集算法-工作机制MinorGC、 Mixed GC 、 FullGC的区别是什么 分代收集算法 什么是分代 在java8时&#xff0c;堆被分为了两份&#xff1a; 新生代和老年代【1&#xff1a;2】 其中&#xff1a; 对于新生代&#xff0c;内部又被分为了三…...

C# Linq源码分析之Take方法

概要 Take方法作为IEnumerable的扩展方法&#xff0c;具体对应两个重载方法。本文主要分析第一个接收整数参数的重载方法。 源码解析 Take方法的基本定义 public static System.Collections.Generic.IEnumerable Take (this System.Collections.Generic.IEnumerable source…...

从后往前读取列表的方法

从后往前读取列表的方法 方法1&#xff1a;使用for循环遍历列表时&#xff0c;可以使用reverse()函数将列表反转&#xff0c;然后再遍历。 # 列表 num [0, 1, 2, 3]# 反向遍历 for i in reversed(num):print(i)输出结果&#xff1a; 3 2 1 0方法2&#xff1a;先计算列表长度…...

数据库--数据类型

数据库相关链接&#xff1a; 数据库基础操作--增删改查&#xff1a;http://t.csdn.cn/189CF 数据库--三大范式、多表查询、函数sql&#xff1a;http://t.csdn.cn/udJSG 数据类型 创建表的时候&#xff0c;我们在类型这里给出了不同的选项&#xff0c;比如有int &#xff0c;…...

小型双轮差速底盘机器人实现红外跟随功能

1. 功能说明 本文示例将实现R023样机小型双轮差速底盘跟随人移动的功能。在小型双轮差速底盘前方按下图所示安装3个 近红外传感器&#xff0c;制作一个红外线发射源&#xff0c;实现当红外发射源在机器人的检测范围内任意放置或移动时&#xff0c;机器人能追踪该发射源。 2. 电…...

TCP协议网络编程 回显服务器,客户端实现

回显服务器表示客户端传来的请求是什么&#xff0c;服务器就回应什么&#xff0c;客户端不用对传来的数据进行处理&#xff0c;主要是为了熟悉TCP协议提供的API的使用 对于代码的解释全作为注释写在了代码上&#xff0c;推荐复制到编程软件中查看 UDP协议实现回显服务器可以看…...

3.4 Spring MVC注解

注解名称 注解说明 RequestMapping 用来处理请求地址映射的注解&#xff0c;可以在接口、类和方法上使用 value属性 表示请求地址&#xff0c;与path属性一致 method属性 表示接收HTTP请求方法&#xff0c;默认接收所有请求方法&#xff0c;请求包括GET、POST、PUT、DEL…...

OpenCV实例(八)车牌字符识别技术(三)汉字识别

车牌字符识别技术&#xff08;三&#xff09;汉字识别 1.代码实例2.遇到问题3.汉字识别代码实例 相较于数字和英文字符的识别&#xff0c;汽车牌照中的汉字字符识别的难度更大&#xff0c;主要原因有以下4个方面&#xff1a; (1)字符笔画因切分误差导致非笔画或笔画流失。 (2…...

运维监控学习笔记2

硬件监控&#xff1a; 1&#xff09;使用IPMI 2&#xff09;机房巡检 路由器和交换机&#xff1a; 使用SNMP&#xff08;简单网络管理协议&#xff09;进行监控。 Linux 安装snmp&#xff1a; yum install -y net-snmp net-snmp-utils 说明&#xff1a;net-snmp是安装在snm…...

【深度学习】遗传算法[选择、交叉、变异、初始化种群、迭代优化、几何规划排序选择、线性交叉、非均匀变异]

目录 一、遗传算法二、遗传算法概述2.1 选择2.2 交叉2.3 变异 三、遗传算法的基本步骤3.1 编码3.2 初始群体的生成3.3 适应度评估3.4 选择3.5 交叉3.6 变异3.7 总结 四、遗传算法工具箱4.1 initializega4.2 ga4.3 normGeomSelect4.4 arithXover4.5 nonUnifMutation 五、遗传算法…...

【小吉带你学Git】讲解GitHub操作,码云操作,GitLab操作

&#x1f38a;专栏【Git】 &#x1f354;喜欢的诗句&#xff1a;更喜岷山千里雪 三军过后尽开颜。 &#x1f386;音乐分享【如愿】 &#x1f33a;欢迎并且感谢大家指出小吉的问题&#x1f970; 文章目录 &#x1f354;GitHub操作⭐安装GitHub插件⭐在idea中设置GitHub账号&…...

nginx基础

nginx 具体就是一个轻量级以及高性能的web服务软件。 nginx特点 1、稳定性高。&#xff08;但不如apache&#xff09; 2、系统资源消耗比较低。&#xff08;处理http请求的并发能力较高&#xff0c;单台处理器可以处理3w-5w的并发请求&#xff09; 注&#xff1a;一般在企…...

【Windows API】获取卷标、卷名

1、卷->卷标 使用FindFirstVolume()和FindNextVolume()函数体系&#xff0c;枚举系统所有卷&#xff08;Volume&#xff09;的例子&#xff0c;然后获取卷标、卷类型。这个方式可以枚举出没有驱动器号&#xff08;卷标&#xff09;的卷。 int TestMode1() {HANDLE hVolume…...

通过MATLAB自动产生Hamming编译码的verilog实现,包含testbench

目录 1.算法运行效果图预览 2.算法运行软件版本 3.部分核心程序 4.算法理论概述 1. 原理 1.1 编码规则 1.2 错误检测和纠正 2. 实现过程 2.1 编码过程 2.2 解码过程 3. 应用领域 3.1 数字通信 3.2 存储系统 3.3 ECC内存 3.4 数据传输 5.算法完整程序工程 1.算法…...

swager web服务无法显示问题

如果指定了扫描其他包 那么web文件夹里面的就扫描不到 需要加上扫描扫描web的 &#xff0c;默认什么也没有就会扫描web文件夹 但是其他模块的扫描不到 指定了扫描其他模块就需要再次指定扫描该web文件夹...

代码随想录训练营day18 二叉树

106. 从中序与后序遍历序列构造二叉树 给定两个整数数组 inorder 和 postorder &#xff0c;其中 inorder 是二叉树的中序遍历&#xff0c; postorder 是同一棵树的后序遍历&#xff0c;请你构造并返回这颗 二叉树 。 //左根右 左右根/* 第一步&#xff1a;如果数组大小为零的…...

图像的平移变换之c++实现(qt + 不调包)

1.基本原理 设dx为水平偏移量&#xff0c;dy为垂直偏移量&#xff0c;则平移变换的坐标映射关系为下公式&#xff0c;图像平移一般有两种方式。 1.不改变图像大小的平移&#xff08;一旦平移&#xff0c;相应内容被截掉&#xff09; 1&#xff09;当dx > width、dx < -wi…...

云原生K8S------Yaml文件详解

目录 一&#xff1a;K8S支持的文件格式 1&#xff0c;yaml和json的主要区别 2&#xff0c;YAML语言格式 二&#xff1a;yuml 1、查看 api 资源版本标签 2、写一个yaml文件demo 3、创建service服务对外提供访问并测试 4、详解k8s中的port 三&#xff1a;文件生成 1、kubec…...

测试开发环境安装

安装python运行环境 下载地址&#xff1a;链接 http://python.p2hp.com/downloads/windows/index.html 选择合适自己的版&#xff0c;我下载的3.8.10的进行安装 安装码编辑器Pychrom 下载地址&#xff1a;链接 https://www.jetbrains.com/pycharm/ 拉到最下面可以下载社区版…...

利用最小二乘法找圆心和半径

#include <iostream> #include <vector> #include <cmath> #include <Eigen/Dense> // 需安装Eigen库用于矩阵运算 // 定义点结构 struct Point { double x, y; Point(double x_, double y_) : x(x_), y(y_) {} }; // 最小二乘法求圆心和半径 …...

JavaSec-RCE

简介 RCE(Remote Code Execution)&#xff0c;可以分为:命令注入(Command Injection)、代码注入(Code Injection) 代码注入 1.漏洞场景&#xff1a;Groovy代码注入 Groovy是一种基于JVM的动态语言&#xff0c;语法简洁&#xff0c;支持闭包、动态类型和Java互操作性&#xff0c…...

基于FPGA的PID算法学习———实现PID比例控制算法

基于FPGA的PID算法学习 前言一、PID算法分析二、PID仿真分析1. PID代码2.PI代码3.P代码4.顶层5.测试文件6.仿真波形 总结 前言 学习内容&#xff1a;参考网站&#xff1a; PID算法控制 PID即&#xff1a;Proportional&#xff08;比例&#xff09;、Integral&#xff08;积分&…...

【人工智能】神经网络的优化器optimizer(二):Adagrad自适应学习率优化器

一.自适应梯度算法Adagrad概述 Adagrad&#xff08;Adaptive Gradient Algorithm&#xff09;是一种自适应学习率的优化算法&#xff0c;由Duchi等人在2011年提出。其核心思想是针对不同参数自动调整学习率&#xff0c;适合处理稀疏数据和不同参数梯度差异较大的场景。Adagrad通…...

【WiFi帧结构】

文章目录 帧结构MAC头部管理帧 帧结构 Wi-Fi的帧分为三部分组成&#xff1a;MAC头部frame bodyFCS&#xff0c;其中MAC是固定格式的&#xff0c;frame body是可变长度。 MAC头部有frame control&#xff0c;duration&#xff0c;address1&#xff0c;address2&#xff0c;addre…...

【力扣数据库知识手册笔记】索引

索引 索引的优缺点 优点1. 通过创建唯一性索引&#xff0c;可以保证数据库表中每一行数据的唯一性。2. 可以加快数据的检索速度&#xff08;创建索引的主要原因&#xff09;。3. 可以加速表和表之间的连接&#xff0c;实现数据的参考完整性。4. 可以在查询过程中&#xff0c;…...

线程同步:确保多线程程序的安全与高效!

全文目录&#xff1a; 开篇语前序前言第一部分&#xff1a;线程同步的概念与问题1.1 线程同步的概念1.2 线程同步的问题1.3 线程同步的解决方案 第二部分&#xff1a;synchronized关键字的使用2.1 使用 synchronized修饰方法2.2 使用 synchronized修饰代码块 第三部分&#xff…...

可靠性+灵活性:电力载波技术在楼宇自控中的核心价值

可靠性灵活性&#xff1a;电力载波技术在楼宇自控中的核心价值 在智能楼宇的自动化控制中&#xff0c;电力载波技术&#xff08;PLC&#xff09;凭借其独特的优势&#xff0c;正成为构建高效、稳定、灵活系统的核心解决方案。它利用现有电力线路传输数据&#xff0c;无需额外布…...

DIY|Mac 搭建 ESP-IDF 开发环境及编译小智 AI

前一阵子在百度 AI 开发者大会上&#xff0c;看到基于小智 AI DIY 玩具的演示&#xff0c;感觉有点意思&#xff0c;想着自己也来试试。 如果只是想烧录现成的固件&#xff0c;乐鑫官方除了提供了 Windows 版本的 Flash 下载工具 之外&#xff0c;还提供了基于网页版的 ESP LA…...

04-初识css

一、css样式引入 1.1.内部样式 <div style"width: 100px;"></div>1.2.外部样式 1.2.1.外部样式1 <style>.aa {width: 100px;} </style> <div class"aa"></div>1.2.2.外部样式2 <!-- rel内表面引入的是style样…...