CN115801286A - Calling method, device, equipment and storage medium of microservice - Google Patents
Calling method, device, equipment and storage medium of microservice Download PDFInfo
- Publication number
- CN115801286A CN115801286A CN202211659070.9A CN202211659070A CN115801286A CN 115801286 A CN115801286 A CN 115801286A CN 202211659070 A CN202211659070 A CN 202211659070A CN 115801286 A CN115801286 A CN 115801286A
- Authority
- CN
- China
- Prior art keywords
- microservice
- service discovery
- plaintext
- provider
- secret key
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Storage Device Security (AREA)
Abstract
Description
技术领域technical field
本发明实施例涉及微服务技术领域,尤其涉及一种微服务的调用方法、装置、设备及存储介质。Embodiments of the present invention relate to the technical field of microservices, and in particular, to a method, device, device, and storage medium for invoking microservices.
背景技术Background technique
微服务点对点通讯是指两个微服务之间直接信息交换,应用的请求或者响应无需经过网关或其他中台系统。微服务提供方会在注册中心注册,访消费方系统定时访问注册中心进行服务发现以更新本地的提供方地址并根据服务发现的结果直连对应的提供方,实现点对点通信。Microservice peer-to-peer communication refers to direct information exchange between two microservices, and application requests or responses do not need to go through gateways or other middle-end systems. The microservice provider will register in the registration center, and the access consumer system regularly visits the registration center for service discovery to update the local provider address and directly connects to the corresponding provider according to the service discovery result to achieve point-to-point communication.
现有方式注册中心对消费方的服务发现请求的身份校验方式简单,容易造成数据泄露,安全性不高。In the existing way, the identity verification method of the registration center for the consumer's service discovery request is simple, which is easy to cause data leakage, and the security is not high.
发明内容Contents of the invention
本发明实施例提供一种微服务的调用方法、装置、设备及存储介质,可以提高微服务调用的安全性。Embodiments of the present invention provide a microservice invocation method, device, device, and storage medium, which can improve the security of microservice invocation.
根据本发明的一方面,提供了一种微服务的调用方法,包括:According to one aspect of the present invention, a microservice calling method is provided, including:
获取消费方发起服务发现请求时的第一时间戳;Obtain the first timestamp when the consumer initiates the service discovery request;
基于多个秘钥对所述第一时间戳和所述消费方的微服务标识进行加密,获得身份认证信息;Encrypting the first timestamp and the microservice identifier of the consumer based on multiple secret keys to obtain identity authentication information;
将所述身份认证信息和所述服务发现请求发送至注册中心,以使所述注册中心对所述身份认证信息进行验证,若验证通过,则向所述消费方返回服务发现响应结果;Sending the identity authentication information and the service discovery request to a registration center, so that the registration center can verify the identity authentication information, and if the verification is passed, return a service discovery response result to the consumer;
接收所述注册中心返回的服务发现响应结果,并根据所述服务发现响应结果调用提供方的微服务实例;其中,所述服务发现响应结果包括提供方地址。Receive the service discovery response result returned by the registration center, and invoke the microservice instance of the provider according to the service discovery response result; wherein, the service discovery response result includes the provider address.
可选的,所述多个秘钥包括三个秘钥,分别是第一秘钥、第二秘钥和第三秘钥;基于多个秘钥对所述第一时间戳和所述消费方的微服务标识进行加密,获得身份认证信息,包括:Optionally, the multiple secret keys include three secret keys, which are a first secret key, a second secret key, and a third secret key; Encrypt the microservice ID to obtain identity authentication information, including:
对所述第一秘钥的密文进行解码,获得第一秘钥的明文;Decoding the ciphertext of the first secret key to obtain the plaintext of the first secret key;
基于所述第一秘钥的明文获取所述第二秘钥的明文和所述第三秘钥的明文;Obtaining the plaintext of the second key and the plaintext of the third key based on the plaintext of the first key;
将所述第二秘钥的明文、所述第一时间戳和所述消费方的微服务标识进行组合,获得组合信息;combining the plaintext of the second secret key, the first timestamp and the microservice identifier of the consumer to obtain combination information;
基于所述第三秘钥的明文对所述组合信息进行加密,获得身份认证信息。The combination information is encrypted based on the plaintext of the third secret key to obtain identity authentication information.
可选的,基于所述第一秘钥的明文获取所述第二秘钥的明文和所述第三秘钥的明文,包括:Optionally, obtaining the plaintext of the second key and the plaintext of the third key based on the plaintext of the first key includes:
根据所述第一秘钥的明文对所述第二秘钥的密文进行解码,获得第二秘钥的明文;Decoding the ciphertext of the second secret key according to the plaintext of the first secret key to obtain the plaintext of the second secret key;
根据所述第二秘钥的明文对所述第三秘钥的密文进行解码,获得第三秘钥的明文。Decoding the ciphertext of the third key according to the plaintext of the second key to obtain the plaintext of the third key.
可选的,所述注册中心对所述身份认证信息的验证方式为:Optionally, the verification method of the registration center for the identity authentication information is:
根据所述第三秘钥的明文对所述身份认证信息进行解密,获得所述第二秘钥的明文、所述第一时间戳和所述消费方的微服务标识;Decrypt the identity authentication information according to the plaintext of the third secret key, and obtain the plaintext of the second secret key, the first timestamp and the microservice identifier of the consumer;
获取解密时的第二时间戳;Obtain the second timestamp when decrypting;
对所述第二秘钥的明文和所述消费方的微服务标识的合法性进行验证;Verifying the legitimacy of the plaintext of the second secret key and the microservice identifier of the consumer;
根据所述第二时间戳和所述第一时间戳进行时效性验证。Perform timeliness verification according to the second timestamp and the first timestamp.
可选的,所述服务发现响应结果还包括提供方接口及访问权限开关状态;根据所述服务发现响应结果调用提供方的微服务实例,包括:Optionally, the service discovery response result also includes the provider interface and the status of the access permission switch; calling the provider’s microservice instance according to the service discovery response result includes:
若所述访问权限开关状态为打开状态,则获取具有访问权限的接口;If the state of the access right switch is on, then obtain the interface with the access right;
根据所述提供方地址与所述提供方建立连接,并通过具有访问权限的接口调用所述提供方的微服务实例。A connection is established with the provider according to the address of the provider, and a microservice instance of the provider is invoked through an interface with access authority.
可选的,所述服务发现响应结果还包括灰度控制器地址及灰度开关状态,根据所述服务发现响应结果调用提供方的微服务实例,包括:Optionally, the service discovery response result also includes the grayscale controller address and the grayscale switch state, and the microservice instance of the provider is invoked according to the service discovery response result, including:
若所述灰度开关状态为打开状态,则根据所述灰度控制器地址从灰度控制器中获取灰度版本信息;If the state of the grayscale switch is on, then obtain the grayscale version information from the grayscale controller according to the address of the grayscale controller;
根据所述服务发现响应结果调用所述灰度版本信息对应的微服务实例。Invoking the microservice instance corresponding to the grayscale version information according to the service discovery response result.
可选的,根据所述服务发现响应结果调用提供方的微服务实例,包括:Optionally, invoking the microservice instance of the provider according to the service discovery response result includes:
若所述灰度开关状态为关闭状态,且所述调用提供方的微服务实例包含两个或两个以上的版本,则基于负载均衡原理调用所述提供方的两个或两个以上的版本的微服务实例。If the state of the grayscale switch is off, and the microservice instance of the calling provider contains two or more versions, call two or more versions of the provider based on the principle of load balancing microservice instance.
根据本发明的另一方面,提供了一种微服务的调用装置,包括:According to another aspect of the present invention, a microservice invocation device is provided, including:
第一时间戳获取模块,用于获取消费方发起服务发现请求时的第一时间戳;A first timestamp acquisition module, configured to acquire the first timestamp when the consumer initiates a service discovery request;
身份认证信息获取模块,用于基于多个秘钥对所述第一时间戳和所述消费方的微服务标识进行加密,获得身份认证信息;An identity authentication information acquisition module, configured to encrypt the first timestamp and the microservice identifier of the consumer based on a plurality of secret keys to obtain identity authentication information;
信息验证模块,用于将所述身份认证信息和所述服务发现请求发送至注册中心,以使所述注册中心对所述身份认证信息进行验证,若验证通过,则向所述消费方返回服务发现响应结果;An information verification module, configured to send the identity authentication information and the service discovery request to the registration center, so that the registration center can verify the identity authentication information, and return the service to the consumer if the verification is passed. Find the response result;
微服务实例调用模块,用于接收所述注册中心返回的服务发现响应结果,并根据所述服务发现响应结果调用提供方的微服务实例;其中,所述服务发现响应结果包括提供方地址。The microservice instance calling module is configured to receive the service discovery response result returned by the registration center, and call the microservice instance of the provider according to the service discovery response result; wherein, the service discovery response result includes the provider address.
根据本发明的另一方面,提供了一种电子设备,所述电子设备包括:According to another aspect of the present invention, an electronic device is provided, and the electronic device includes:
至少一个处理器;以及at least one processor; and
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的计算机程序,所述计算机程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行本发明任一实施例所述的微服务的调用方法。The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor, so that the at least one processor can execute the method described in any embodiment of the present invention. The calling method of the microservice.
根据本发明的另一方面,提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使处理器执行时实现本发明任一实施例所述的微服务的调用方法。According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement any of the embodiments of the present invention when executed. The calling method of the microservice.
本发明通过获取消费方发起服务发现请求时的第一时间戳;基于多个秘钥对所述第一时间戳和所述消费方的微服务标识进行加密,获得身份认证信息;将所述身份认证信息和所述服务发现请求发送至注册中心,以使所述注册中心对所述身份认证信息进行验证,若验证通过,则向所述消费方返回服务发现响应结果;接收所述注册中心返回的服务发现响应结果,并根据所述服务发现响应结果调用提供方的微服务实例;其中,所述服务发现响应结果包括提供方地址。通过本发明的技术方案,可以提高微服务调用的安全性。The present invention obtains the first time stamp when the consumer initiates a service discovery request; encrypts the first time stamp and the microservice identifier of the consumer based on multiple secret keys to obtain identity authentication information; The authentication information and the service discovery request are sent to the registration center, so that the registration center can verify the identity authentication information, and if the verification is passed, return the service discovery response result to the consumer; receive the registration center return The service discovery response result, and invoke the microservice instance of the provider according to the service discovery response result; wherein, the service discovery response result includes the provider address. Through the technical scheme of the invention, the security of microservice invocation can be improved.
附图说明Description of drawings
为了更清楚地说明本发明实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本发明的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to illustrate the technical solutions of the embodiments of the present invention more clearly, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention, and thus It should be regarded as a limitation on the scope, and those skilled in the art can also obtain other related drawings based on these drawings without creative work.
图1是根据本发明实施例一提供的一种微服务的调用方法的流程图;FIG. 1 is a flow chart of a microservice calling method provided according to Embodiment 1 of the present invention;
图2是根据本发明实施例一提供的微服务实例调用流程示例图;FIG. 2 is an example diagram of a microservice instance invocation process provided according to Embodiment 1 of the present invention;
图3是根据本发明实施例二提供的一种微服务的调用方法的流程图;FIG. 3 is a flow chart of a microservice calling method provided according to Embodiment 2 of the present invention;
图4是根据本发明实施例三提供的一种微服务的调用装置的结构示意图;FIG. 4 is a schematic structural diagram of a microservice calling device provided according to Embodiment 3 of the present invention;
图5是根据本发明实施例四提供的一种电子设备的结构示意图。FIG. 5 is a schematic structural diagram of an electronic device according to Embodiment 4 of the present invention.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。In order to enable those skilled in the art to better understand the solutions of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only It is an embodiment of a part of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present invention.
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first" and "second" in the description and claims of the present invention and the above drawings are used to distinguish similar objects, but not necessarily used to describe a specific sequence or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the invention described herein can be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having", as well as any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method, system, product or device comprising a sequence of steps or elements is not necessarily limited to the expressly listed instead, may include other steps or elements not explicitly listed or inherent to the process, method, product or apparatus.
实施例一Embodiment one
图1是根据本发明实施例一提供的一种微服务的调用方法的流程图,本实施例可适用于对微服务实例进行调用的情况,该方法可以由一种微服务的调用转朱阁装置来执行,具体包括如下步骤:Fig. 1 is a flow chart of a method for invoking a microservice according to Embodiment 1 of the present invention. This embodiment is applicable to the case of invoking a microservice instance, and the method can be transferred from a microservice invocation device, specifically including the following steps:
步骤110、获取消费方发起服务发现请求时的第一时间戳。Step 110, acquiring the first time stamp when the consumer initiates the service discovery request.
其中,消费方可以理解为需要调用微服务实例的一方。消费方可以发起服务发现请求。服务发现请求可以理解为调用微服务实例的请求。第一时间戳可以理解为是消费方发起服务发现请求的时间。本实施例中可以获取消费方发起服务发现请求时的时间信息。Among them, the consumer can be understood as the party that needs to call the microservice instance. Consumers can initiate service discovery requests. A service discovery request can be understood as a request to invoke a microservice instance. The first timestamp can be understood as the time when the consumer initiates the service discovery request. In this embodiment, the time information when the consumer initiates the service discovery request can be obtained.
步骤120、基于多个秘钥对所述第一时间戳和所述消费方的微服务标识进行加密,获得身份认证信息。Step 120: Encrypt the first timestamp and the microservice identifier of the consumer based on multiple secret keys to obtain identity authentication information.
其中,多个秘钥可以包括三个秘钥,分别是第一秘钥、第二秘钥和第三秘钥。微服务标识可以微服务的标识信息,例如,微服务标识可以是微服务ID信息,还可以是其他标识信息。可以理解的,本实施例中在用户注册申请微服务平台时,就可以申请到微服务标识和提供方接口权限等信息。加密可以的通过加密算法等方式进行加密,还可以通过其他方式进行加密。身份认证信息可以是对消费方的身份进行认证的信息,可以用于对消费方进行身份认证。身份认证信息可以是通过多个秘钥对第一时间戳和消费方的微服务标识进行加密得到的。本实施例中可以基于多个秘钥对第一时间戳和消费方的微服务标进行加密,以获得身份认证信息。Wherein, the plurality of secret keys may include three secret keys, which are respectively a first secret key, a second secret key and a third secret key. The microservice identifier may be identification information of the microservice, for example, the microservice identifier may be microservice ID information, or other identification information. It can be understood that, in this embodiment, when the user registers and applies for the microservice platform, he can apply for information such as the microservice identifier and provider interface authority. Encryption can be encrypted by means of encryption algorithm, etc., and can also be encrypted by other means. The identity authentication information may be information for authenticating the identity of the consumer, and may be used to authenticate the identity of the consumer. The identity authentication information may be obtained by encrypting the first timestamp and the consumer's microservice identifier with multiple secret keys. In this embodiment, the first time stamp and the consumer's microservice token may be encrypted based on multiple secret keys to obtain identity authentication information.
在本实施例中,可选的,所述多个秘钥包括三个秘钥,分别是第一秘钥、第二秘钥和第三秘钥;基于多个秘钥对所述第一时间戳和所述消费方的微服务标识进行加密,获得身份认证信息,包括:对所述第一秘钥的密文进行解码,获得第一秘钥的明文;基于所述第一秘钥的明文获取所述第二秘钥的明文和所述第三秘钥的明文;将所述第二秘钥的明文、所述第一时间戳和所述消费方的微服务标识进行组合,获得组合信息;基于所述第三秘钥的明文对所述组合信息进行加密,获得身份认证信息。In this embodiment, optionally, the multiple secret keys include three secret keys, which are respectively the first secret key, the second secret key and the third secret key; stamp and the microservice ID of the consumer to obtain identity authentication information, including: decoding the ciphertext of the first secret key to obtain the plaintext of the first secret key; based on the plaintext of the first secret key Obtain the plaintext of the second secret key and the plaintext of the third secret key; combine the plaintext of the second secret key, the first timestamp and the microservice identifier of the consumer to obtain combined information ; Encrypting the combined information based on the plaintext of the third secret key to obtain identity authentication information.
其中,多个秘钥包括三个秘钥,分别是第一秘钥、第二秘钥和第三秘钥。示例性的,第一秘钥可以是GK;第二秘钥可以是PK;第三秘钥可以是WK。本实施例中每个秘钥都包括明文和密文。其中,秘钥的明文可以是通过对秘钥的密文进行解码得到。第一秘钥的明文可以通过对第一秘钥的密文进行解码得到。本实施例中可以基于第一秘钥的明文获取第二秘钥的明文和第三秘钥的明文。组合信息可以的将第二秘钥的明文、第一时间戳和消费方的微服务标识进行组合得到的。本实施例中可以基于第三秘钥的明文对组合信息进行加密得到的身份认证信息。Wherein, the multiple secret keys include three secret keys, which are respectively a first secret key, a second secret key and a third secret key. Exemplarily, the first key may be GK; the second key may be PK; and the third key may be WK. Each key in this embodiment includes plaintext and ciphertext. Wherein, the plaintext of the secret key may be obtained by decoding the ciphertext of the secret key. The plaintext of the first secret key can be obtained by decoding the ciphertext of the first secret key. In this embodiment, the plaintext of the second key and the plaintext of the third key can be obtained based on the plaintext of the first key. The combination information can be obtained by combining the plaintext of the second secret key, the first timestamp and the microservice identifier of the consumer. In this embodiment, the identity authentication information obtained by encrypting the combination information based on the plaintext of the third key may be used.
进一步的,本实施例中的微服务实例调用流程示例图如图2所示,本实施例中当用户第一次接入微服务平台时,需要去服务治理平台上申请对应的消费方、提供方微服务ID作为该应用的唯一标识,而后根据应用属性选择相应的接入环境。本实施例中本实施例中当用户确定接入环境后,用户需要登录门户为每一个微服务应用申请多个密钥如GK、PK和WK,其中GK用户自行保存并配置在应用的配置文件或环境变量中,密钥PK和密钥WK会由门户下发到对应的注册中心和配置中心。其中,门户可以理解为系统的某个页面信息或者服务器。本实施例中生成请求身份信息的三层密钥对称加解密算法相对复杂,且三层密钥加密模式中的PK与WK由平台维护,用户对PK和WK无感,仅需保存GK密钥,大大降低密钥泄露的风险,身份校验安全性更加可靠。Further, an example diagram of the microservice instance invocation process in this embodiment is shown in Figure 2. In this embodiment, when a user accesses the microservice platform for the first time, he needs to apply for the corresponding consumer on the service management platform, provide The party microservice ID is used as the unique identifier of the application, and then the corresponding access environment is selected according to the application attributes. In this embodiment, after the user determines the access environment in this embodiment, the user needs to log in to the portal to apply for multiple keys such as GK, PK, and WK for each microservice application, and the GK user saves and configures it in the configuration file of the application or environment variables, the key PK and key WK will be issued by the portal to the corresponding registration center and configuration center. Among them, the portal can be understood as a certain page information or server of the system. In this embodiment, the three-layer key symmetric encryption and decryption algorithm for generating request identity information is relatively complicated, and the PK and WK in the three-layer key encryption mode are maintained by the platform, and the user has no sense of PK and WK, and only needs to save the GK key , greatly reducing the risk of key leakage, and the security of identity verification is more reliable.
本实施例中可以对第一秘钥的密文进行解码,获得第一秘钥的明文,基于第一秘钥的明文获取第二秘钥的明文和第三秘钥的明文;将第二秘钥的明文、第一时间戳和消费方的微服务标识进行组合,获得组合信息;基于第三秘钥的明文对组合信息进行加密,获得身份认证信息。本实施例中通过这样的设置,可以通过对三层密钥体系对称加密得到的身份认证信息,进一步提高了身份认证信息的安全性。In this embodiment, the ciphertext of the first secret key can be decoded to obtain the plaintext of the first secret key, and the plaintext of the second secret key and the plaintext of the third secret key can be obtained based on the plaintext of the first secret key; Combine the plaintext of the secret key, the first timestamp and the microservice identifier of the consumer to obtain combined information; encrypt the combined information based on the plaintext of the third secret key to obtain identity authentication information. Through such setting in this embodiment, the identity authentication information obtained by symmetrically encrypting the three-layer key system can further improve the security of the identity authentication information.
在本实施例中,可选的,基于所述第一秘钥的明文获取所述第二秘钥的明文和所述第三秘钥的明文,包括:根据所述第一秘钥的明文对所述第二秘钥的密文进行解码,获得第二秘钥的明文;根据所述第二秘钥的明文对所述第三秘钥的密文进行解码,获得第三秘钥的明文。In this embodiment, optionally, obtaining the plaintext of the second key and the plaintext of the third key based on the plaintext of the first key includes: pairing the plaintext of the first key to Decoding the ciphertext of the second secret key to obtain the plaintext of the second secret key; decoding the ciphertext of the third secret key according to the plaintext of the second secret key to obtain the plaintext of the third secret key.
其中,第二秘钥的明文可以是根据第一秘钥的明文对第二秘钥的密文进行解码得到的。第三秘钥的明文可以是根据第二秘钥的明文对第三秘钥的密文进行解码得到的。示例性的,本实施例中可以根据秘钥GK的明文对秘钥PK的密文进行解码,以获得秘钥PK的明文;根据秘钥PK的明文对秘钥WK的密文进行解码,从而得到秘钥WK明文。Wherein, the plaintext of the second key may be obtained by decoding the ciphertext of the second key according to the plaintext of the first key. The plaintext of the third key may be obtained by decoding the ciphertext of the third key according to the plaintext of the second key. Exemplarily, in this embodiment, the ciphertext of the key PK can be decoded according to the plaintext of the key GK to obtain the plaintext of the key PK; the ciphertext of the key WK can be decoded according to the plaintext of the key PK, thereby Obtain the plaintext of the secret key WK.
本实施例中可以根据第一秘钥的明文对第二秘钥的密文进行解码,以获得第二秘钥的明文;然后根据第二秘钥的明文对第三秘钥的密文进行解码,以获得第三秘钥的明文。本实施例中通过这样的设置,可以通过对三层秘钥的密文进行解码得到秘钥的明文,从而获得身份认证信息,便于后续进行身份认证信息进行验证。In this embodiment, the ciphertext of the second key can be decoded according to the plaintext of the first key to obtain the plaintext of the second key; and then the ciphertext of the third key can be decoded according to the plaintext of the second key , to obtain the plaintext of the third key. With such a setting in this embodiment, the plaintext of the secret key can be obtained by decoding the ciphertext of the three-layer secret key, so as to obtain the identity authentication information, which facilitates subsequent verification of the identity authentication information.
在本实施例中,可选的,所述注册中心对所述身份认证信息的验证方式为:根据所述第三秘钥的明文对所述身份认证信息进行解密,获得所述第二秘钥的明文、所述第一时间戳和所述消费方的微服务标识;获取解密时的第二时间戳;对所述第二秘钥的明文和所述消费方的微服务标识的合法性进行验证;根据所述第二时间戳和所述第一时间戳进行时效性验证。In this embodiment, optionally, the registration center verifies the identity authentication information by: decrypting the identity authentication information according to the plaintext of the third secret key to obtain the second secret key the plaintext of the first timestamp and the microservice ID of the consumer; obtain the second timestamp when decrypted; check the legitimacy of the plaintext of the second secret key and the microservice ID of the consumer Verifying: performing timeliness verification according to the second timestamp and the first timestamp.
其中,解密可以是通过解密算法进行解密,也可以是通过其他方式进行解密。本实施例中可以根据第三秘钥的明文对身份认证信息进行解密,以获得第二秘钥的明文、第一时间戳和消费方的微服务标识。第二时间戳可以理解为具体的时间信息。本实施例中可以获取解密时的时间信息。合法性进行验证可以理解为对需要验证的对象进行比对验证是否合法。本实施例中可以对第二秘钥的明文和消费方的微服务标识的合法性进行验证可以是注册中心通过对第二秘钥的明文与缓存中的秘钥信息进行比对确定是否具备合法性,若第二秘钥的明文与缓存中的秘钥信息的比对结果一致,则确定具备合法性;若比对结果不一致,则确定不具备合法性。以及注册中心通过对消费方的微服务标识与缓存中的标识信息进行比对确定是否具备合法性;若对消费方的微服务标识与缓存中的标识信息的比对结果一致,则确定具备合法性;若比对结果不一致,则确定不具备合法性。Wherein, the decryption may be performed through a decryption algorithm, or may be performed through other methods. In this embodiment, the identity authentication information may be decrypted according to the plaintext of the third key to obtain the plaintext of the second key, the first timestamp, and the microservice identifier of the consumer. The second timestamp can be understood as specific time information. In this embodiment, the time information at the time of decryption can be obtained. Verifying legality can be understood as comparing and verifying whether the object to be verified is legal. In this embodiment, the legitimacy of the plaintext of the second secret key and the microservice ID of the consumer can be verified. The registration center can determine whether it is legal by comparing the plaintext of the second secret key with the secret key information in the cache. If the comparison result of the plaintext of the second secret key is consistent with the secret key information in the cache, it is determined to be legal; if the comparison result is inconsistent, it is determined not to be legal. And the registration center determines whether it is legal by comparing the consumer's microservice identifier with the identifier information in the cache; if the comparison result of the consumer's microservice identifier and the identifier information in the cache is consistent, it is determined to be legal If the comparison results are not consistent, it is determined that they do not have legality.
时效性验证可以理解为得到的时长是否超过预设阈值,从而判断是否具备时效性。其中,预设阈值可以是预先设置好的,可以根据实际需求进行设置。具体的,本实施例中根据第二时间戳和第一时间戳进行时效性验证可以是通过将第二时间戳减去第一时间戳得到的时长,将时长与预设阈值进行比较,判断是否超过预设阈值,若时长超过预设时长,则不具备时效性;若时长未超过预设时长,则具备时效性。Timeliness verification can be understood as whether the obtained duration exceeds the preset threshold, so as to judge whether it is timeliness. Wherein, the preset threshold may be preset, and may be set according to actual requirements. Specifically, in this embodiment, the timeliness verification based on the second timestamp and the first timestamp may be obtained by subtracting the second timestamp from the first timestamp, comparing the duration with a preset threshold, and judging whether Exceeding the preset threshold, if the duration exceeds the preset duration, it is not time-sensitive; if the duration does not exceed the preset duration, it is time-sensitive.
本实施例中可以根据第三秘钥的明文对所述身份认证信息进行解密,获得第二秘钥的明文、第一时间戳和消费方的微服务标识,通过获取解密时的第二时间戳,对第二秘钥的明文和消费方的微服务标识的合法性进行验证,以及根据第二时间戳和第一时间戳进行时效性验证,从而完成对身份认证信息的验证。本实施例中通过合法性验证以及时效性验证,最终完成对身份认证信息的验证,进一步提高了提高微服务调用的安全性。In this embodiment, the identity authentication information can be decrypted according to the plaintext of the third secret key to obtain the plaintext of the second secret key, the first timestamp and the microservice identifier of the consumer, and by obtaining the second timestamp at the time of decryption , verify the legitimacy of the plaintext of the second secret key and the microservice identifier of the consumer, and perform timeliness verification according to the second timestamp and the first timestamp, thereby completing the verification of the identity authentication information. In this embodiment, through legality verification and timeliness verification, the verification of identity authentication information is finally completed, which further improves the security of microservice calls.
步骤130、将所述身份认证信息和所述服务发现请求发送至注册中心,以使所述注册中心对所述身份认证信息进行验证,若验证通过,则向所述消费方返回服务发现响应结果。Step 130: Send the identity authentication information and the service discovery request to the registration center, so that the registration center can verify the identity authentication information, and if the verification is passed, return the service discovery response result to the consumer .
其中,注册中心可以对身份认证信息进行验证。服务发现响应结果可以是对身份认证信息进行验证通过返回的结果信息。本实施例中可以将身份认证信息和服务发现请求发送至注册中心,以使注册中心对身份认证信息进行验证,若验证通过,则向消费方返回服务发现响应结果。Wherein, the registration center can verify the identity authentication information. The service discovery response result may be the result information returned after verifying the identity authentication information. In this embodiment, the identity authentication information and service discovery request can be sent to the registration center, so that the registration center can verify the identity authentication information, and return the service discovery response result to the consumer if the verification is passed.
步骤140、接收所述注册中心返回的服务发现响应结果,并根据所述服务发现响应结果调用提供方的微服务实例。Step 140: Receive the service discovery response result returned by the registration center, and invoke the microservice instance of the provider according to the service discovery response result.
其中,所述服务发现响应结果包括提供方地址。微服务实例可以具有应用版本信息,例如,每个微服务实例可以包括多个版本信息,如版本一、版本二以及版本三等版本信息。本实施例中可以根据提供方的地址对提供方的微服务实例进行调用。本实施例中消费方可以接收注册中心返回的服务发现响应结果,并根据服务发现响应结果的提供方地址调用提供方的微服务实例。Wherein, the service discovery response result includes a provider address. A microservice instance may have application version information. For example, each microservice instance may include multiple version information, such as version 1, version 2, and version 3. In this embodiment, the provider's microservice instance can be called according to the provider's address. In this embodiment, the consumer can receive the service discovery response result returned by the registration center, and call the provider's microservice instance according to the provider address of the service discovery response result.
本发明通过获取消费方发起服务发现请求时的第一时间戳;基于多个秘钥对所述第一时间戳和所述消费方的微服务标识进行加密,获得身份认证信息;将所述身份认证信息和所述服务发现请求发送至注册中心,以使所述注册中心对所述身份认证信息进行验证,若验证通过,则向所述消费方返回服务发现响应结果;接收所述注册中心返回的服务发现响应结果,并根据所述服务发现响应结果调用提供方的微服务实例;其中,所述服务发现响应结果包括提供方地址。通过本发明的技术方案,可以提高微服务调用的安全性。The present invention obtains the first time stamp when the consumer initiates a service discovery request; encrypts the first time stamp and the microservice identifier of the consumer based on multiple secret keys to obtain identity authentication information; The authentication information and the service discovery request are sent to the registration center, so that the registration center can verify the identity authentication information, and if the verification is passed, return the service discovery response result to the consumer; receive the registration center return The service discovery response result, and invoke the microservice instance of the provider according to the service discovery response result; wherein, the service discovery response result includes the provider address. Through the technical scheme of the invention, the security of microservice invocation can be improved.
实施例二Embodiment two
图3是根据本发明实施例二提供的一种微服务的调用方法的流程图,本实施例以上述实施例为基础进行优化。具体优化为:所述服务发现响应结果还包括提供方接口及访问权限开关状态;根据所述服务发现响应结果调用提供方的微服务实例,包括:若所述访问权限开关状态为打开状态,则获取具有访问权限的接口;根据所述提供方地址与所述提供方建立连接,并通过具有访问权限的接口调用所述提供方的微服务实例。如图3所示,本实施例的方法具体包括如下步骤:FIG. 3 is a flow chart of a method for invoking a microservice according to Embodiment 2 of the present invention. This embodiment is optimized on the basis of the foregoing embodiments. The specific optimization is: the service discovery response result also includes the provider interface and the status of the access right switch; calling the provider’s microservice instance according to the service discovery response result includes: if the status of the access right switch is on, then Obtain an interface with access authority; establish a connection with the provider according to the address of the provider, and call the microservice instance of the provider through the interface with access authority. As shown in Figure 3, the method of this embodiment specifically includes the following steps:
步骤310、获取消费方发起服务发现请求时的第一时间戳。Step 310, acquiring the first time stamp when the consumer initiates the service discovery request.
步骤320、基于多个秘钥对所述第一时间戳和所述消费方的微服务标识进行加密,获得身份认证信息。Step 320: Encrypt the first timestamp and the consumer's microservice identifier based on multiple secret keys to obtain identity authentication information.
步骤330、将所述身份认证信息和所述服务发现请求发送至注册中心,以使所述注册中心对所述身份认证信息进行验证,若验证通过,则向所述消费方返回服务发现响应结果。Step 330: Send the identity authentication information and the service discovery request to the registration center, so that the registration center can verify the identity authentication information, and if the verification is passed, return the service discovery response result to the consumer .
步骤340、接收所述注册中心返回的服务发现响应结果。Step 340, receiving the service discovery response result returned by the registration center.
其中,所述服务发现响应结果包括提供方地址。服务发现响应结果还包括提供方接口及访问权限开关状态。提供方接口可以包括具体的可以调用的接口。示例性的,若返回的服务发现响应结果包括的提供方接口为A和接口B,也就是说只能通过具有访问权限的接口A和接口B调用提供方的微服务实例。访问权限开关状态可以包括打开状态和关闭状态。Wherein, the service discovery response result includes a provider address. The service discovery response result also includes the provider interface and access permission switch status. Provider interfaces may include concrete callable interfaces. Exemplarily, if the returned service discovery response result includes provider interface A and interface B, that is to say, the provider's microservice instance can only be invoked through interface A and interface B with access rights. The access permission switch state may include an open state and a closed state.
步骤350、若所述访问权限开关状态为打开状态,则获取具有访问权限的接口。Step 350, if the state of the access right switch is on, acquire an interface with access right.
本实施例中若访问权限开关状态为打开状态,则可以获取具有访问权限的提供方接口。本实施例中若访问权限开关状态为关闭状态,则表明用户申请了所有提供方接口的访问权限,可以访问所有的提供方接口。In this embodiment, if the state of the access right switch is on, the provider interface with the access right can be obtained. In this embodiment, if the state of the access right switch is off, it indicates that the user has applied for the access right to all provider interfaces and can access all provider interfaces.
具体的,本实施例中消费方应用上线前需要在服务治理平台上申请相应提供方的接口调用权限,配置的接口调用权限会由门户后端下发到注册中心,消费方从服务发现响应结果中获取提供方接口及访问权限开关状态,当访问权限开关状态为打开状态时,消费方只能调用已配置调用权限的提供方接口,否则调用接口可以不受限制。Specifically, before the application of the consumer in this embodiment goes online, it needs to apply for the corresponding provider's interface calling authority on the service management platform. Get the provider interface and access permission switch status in . When the access permission switch status is on, the consumer can only call the provider interface with the configured call permission, otherwise the call interface can be unlimited.
步骤360、根据所述提供方地址与所述提供方建立连接,并通过具有访问权限的接口调用所述提供方的微服务实例。
本实施例中可以根据返回的服务发现响应结果中的提供方地址与提供方建立连接,并通过具有访问权限的接口调用提供方的微服务实例。In this embodiment, a connection can be established with the provider according to the provider address in the returned service discovery response result, and the provider's microservice instance can be invoked through an interface with access rights.
示例性的,若具有访问权限的接口只有接口A和接口B,则可以根据提供方地址与提供方建立连接,并通过接口A和接口B调用提供方的微服务实例。本实施例中支持接口调用级别的调用权限配置,使得提供方的接口可选择性的向消费方暴露,提升接口的私密性和灵活性。Exemplarily, if the only interfaces with access rights are interface A and interface B, a connection can be established with the provider according to the address of the provider, and the microservice instance of the provider can be invoked through interface A and interface B. In this embodiment, the call permission configuration of the interface call level is supported, so that the provider's interface can be selectively exposed to the consumer, and the privacy and flexibility of the interface are improved.
在本实施例中,可选的,所述服务发现响应结果还包括灰度控制器地址及灰度开关状态,根据所述服务发现响应结果调用提供方的微服务实例,包括:若所述灰度开关状态为打开状态,则根据所述灰度控制器地址从灰度控制器中获取灰度版本信息;根据所述服务发现响应结果调用所述灰度版本信息对应的微服务实例。In this embodiment, optionally, the service discovery response result further includes the grayscale controller address and the grayscale switch state, and calling the microservice instance of the provider according to the service discovery response result includes: if the grayscale If the state of the grayscale switch is on, the grayscale version information is obtained from the grayscale controller according to the grayscale controller address; and the microservice instance corresponding to the grayscale version information is invoked according to the service discovery response result.
其中,本实施例中的服务发现响应结果还可以包括灰度控制器地址及灰度开关状态。本实施例中可以根据灰度控制器地址访问灰度控制器。灰度开关状态可以包括打开状态和关闭状态。灰度控制器中可以存储优先级较高的微服务实例版本。本实施例中的灰度控制器可以是用户预先配置好的。灰度版本信息可以理解为微服务实例的版本信息。本实施例中可以根据灰度版本信息确定对应的微服务实例。示例性的,如图2所示,本实施例中提供方应用实例若有两个及两个以上的版本,应将版本号信息提前配置在灰度控制器,并将实例配置文件或环境变量中写入相应的灰度信息,这样提供方在注册时会携带灰度版本信息,消费方在做服务发现时获取其灰度版本信息,可以根据获取的灰度发布信息确定灰度控制器中对应的版本的微服务实例。本实施例中将灰度控制器作为提供方注册在注册中心共消费方服务发现,用户在灰度控制器配置的灰度版本信息实时更新,流量分发更加灵活灵敏。Wherein, the service discovery response result in this embodiment may also include the address of the grayscale controller and the state of the grayscale switch. In this embodiment, the grayscale controller can be accessed according to the address of the grayscale controller. The gray switch state may include an on state and an off state. The microservice instance version with higher priority can be stored in the grayscale controller. The grayscale controller in this embodiment may be pre-configured by the user. The grayscale version information can be understood as the version information of the microservice instance. In this embodiment, the corresponding microservice instance can be determined according to the grayscale version information. Exemplarily, as shown in Figure 2, if there are two or more versions of the provider's application instance in this embodiment, the version number information should be configured in the grayscale controller in advance, and the instance configuration file or environment variable In this way, the provider will carry the grayscale version information when registering, and the consumer can obtain the grayscale version information when doing service discovery, and can determine the grayscale version information in the grayscale controller according to the acquired grayscale release information. The microservice instance of the corresponding version. In this embodiment, the grayscale controller is registered as the provider in the registration center and the consumer service is discovered. The grayscale version information configured by the user in the grayscale controller is updated in real time, and the traffic distribution is more flexible and sensitive.
本实施例中若灰度开关状态为打开状态,则表明具有优先级较高版本进行优先调用,则根据灰度控制器地址从灰度控制器中获取灰度版本信息,然后可以根据服务发现响应结果调用灰度版本信息对应的微服务实例;若灰度开关状态为关闭状态,则可以不需要根据灰度版本信息的选择,可以直接根据负载均衡进行调用微服务实例。In this embodiment, if the status of the grayscale switch is on, it indicates that the version with a higher priority is called first, and then the grayscale version information is obtained from the grayscale controller according to the address of the grayscale controller, and then the response can be found according to the service As a result, the microservice instance corresponding to the grayscale version information is invoked; if the grayscale switch status is off, the microservice instance can be directly called according to the load balance without the selection based on the grayscale version information.
具体的,灰度控制器作为公共的提供方注册在注册中心,所有消费方可从服务发现响应结果中获取灰度控制器地址和灰度开关状态,当灰度开关状态为打开状态时,消费方访问灰度控制器获取灰度版本信息,就可以获取提供方版本号然后向指定版本号的提供方实例做负载均衡,从而实现流量的灰度发布;反之,向提供方全版本实例做负载均衡。Specifically, the grayscale controller is registered in the registration center as a public provider, and all consumers can obtain the grayscale controller address and grayscale switch status from the service discovery response results. When the grayscale switch status is on, the consumer If the party accesses the grayscale controller to obtain the grayscale version information, it can obtain the provider's version number and then perform load balancing to the provider instance with the specified version number, so as to realize the grayscale release of traffic; otherwise, load the provider's full version instance balanced.
本实施例中通过这样的设置,可以对灰度版本信息,也就是具有优先级调用的微服务实例进行优先调用做负载均衡,从而实现实现流量的灰度发布,更加便捷。In this embodiment, through such settings, grayscale version information, that is, microservice instances with priority calls can be called preferentially for load balancing, so as to achieve grayscale publishing of traffic, which is more convenient.
在本实施例中,可选的,根据所述服务发现响应结果调用提供方的微服务实例,包括:若所述灰度开关状态为关闭状态,且所述调用提供方的微服务实例包含两个或两个以上的版本,则基于负载均衡原理调用所述提供方的两个或两个以上的版本的微服务实例。In this embodiment, optionally, invoking the microservice instance of the provider according to the service discovery response result includes: if the state of the grayscale switch is off, and the microservice instance of the invoking provider includes two If there are two or more versions, the microservice instances of two or more versions of the provider are invoked based on the principle of load balancing.
其中,负载均衡原理可以理解为基于每个微服务实例的资源状态进行均衡调用。本实施例中若灰度开关状态为关闭状态,且调用提供方的微服务实例包含两个或两个以上的版本,则基于负载均衡原理调用提供方的两个或两个以上的版本的微服务实例。本实施例中通过这样的设置,可以在灰度开关状态为关闭状态下且微服务实例版本两个或两个以上的版本时,对微服务实例可以采用负载均衡原理进行调用,更加便于实现负载均衡,从而实现流量的灰度发布。Among them, the principle of load balancing can be understood as balancing calls based on the resource status of each microservice instance. In this embodiment, if the status of the grayscale switch is off, and the calling provider’s microservice instance contains two or more versions, then the two or more versions of the provider’s microservice instances will be called based on the principle of load balancing. service instance. Through such settings in this embodiment, when the gray switch state is off and there are two or more versions of the microservice instance, the load balancing principle can be used to call the microservice instance, which is more convenient to realize the load balance, so as to realize the grayscale release of traffic.
本发明通过获取消费方发起服务发现请求时的第一时间戳;基于多个秘钥对所述第一时间戳和所述消费方的微服务标识进行加密,获得身份认证信息;将所述身份认证信息和所述服务发现请求发送至注册中心,以使所述注册中心对所述身份认证信息进行验证,若验证通过,则向所述消费方返回服务发现响应结果;接收所述注册中心返回的服务发现响应结果,若所述访问权限开关状态为打开状态,则获取具有访问权限的接口;根据所述提供方地址与所述提供方建立连接,并通过具有访问权限的接口调用所述提供方的微服务实例。其中,所述服务发现响应结果还包括提供方接口及访问权限开关状态。通过本发明的技术方案,可以提高微服务调用的安全性。The present invention obtains the first time stamp when the consumer initiates a service discovery request; encrypts the first time stamp and the microservice identifier of the consumer based on multiple secret keys to obtain identity authentication information; The authentication information and the service discovery request are sent to the registration center, so that the registration center can verify the identity authentication information, and if the verification is passed, return the service discovery response result to the consumer; receive the registration center return The service discovery response result of the service, if the state of the access right switch is on, obtain the interface with the access right; establish a connection with the provider according to the address of the provider, and call the provider through the interface with the access right Party's microservice instance. Wherein, the service discovery response result also includes the provider interface and the status of the access right switch. Through the technical scheme of the invention, the security of microservice invocation can be improved.
实施例三Embodiment Three
图4是根据本发明实施例三提供的一种微服务的调用装置的结构示意图,该装置可执行本发明任意实施例所提供的微服务的调用方法,具备执行方法相应的功能模块和有益效果。如图4所示,该装置包括:Fig. 4 is a schematic structural diagram of a microservice invocation device according to Embodiment 3 of the present invention. The device can execute the microservice invocation method provided in any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the method . As shown in Figure 4, the device includes:
第一时间戳获取模块410,用于获取消费方发起服务发现请求时的第一时间戳;The first
身份认证信息获取模块420,用于基于多个秘钥对所述第一时间戳和所述消费方的微服务标识进行加密,获得身份认证信息;An identity authentication
信息验证模块430,用于将所述身份认证信息和所述服务发现请求发送至注册中心,以使所述注册中心对所述身份认证信息进行验证,若验证通过,则向所述消费方返回服务发现响应结果;An
微服务实例调用模块440,用于接收所述注册中心返回的服务发现响应结果,并根据所述服务发现响应结果调用提供方的微服务实例;其中,所述服务发现响应结果包括提供方地址。The microservice
可选的,所述多个秘钥包括三个秘钥,分别是第一秘钥、第二秘钥和第三秘钥;身份认证信息获取模块420,包括:Optionally, the multiple secret keys include three secret keys, which are respectively the first secret key, the second secret key and the third secret key; the identity authentication
第一明文获取单元,用于对所述第一秘钥的密文进行解码,获得第一秘钥的明文;a first plaintext acquisition unit, configured to decode the ciphertext of the first secret key to obtain the plaintext of the first secret key;
第二明文获取单元,用于基于所述第一秘钥的明文获取所述第二秘钥的明文和所述第三秘钥的明文;a second plaintext acquiring unit, configured to acquire the plaintext of the second secret key and the plaintext of the third secret key based on the plaintext of the first secret key;
组合信息获取单元,用于将所述第二秘钥的明文、所述第一时间戳和所述消费方的微服务标识进行组合,获得组合信息;a combined information acquiring unit, configured to combine the plaintext of the second secret key, the first timestamp and the microservice identifier of the consumer to obtain combined information;
身份认证信息获取单元,用于基于所述第三秘钥的明文对所述组合信息进行加密,获得身份认证信息。The identity authentication information obtaining unit is configured to encrypt the combined information based on the plaintext of the third key to obtain identity authentication information.
可选的,第二明文获取单元,具体用于:Optionally, the second plaintext acquisition unit is specifically used for:
根据所述第一秘钥的明文对所述第二秘钥的密文进行解码,获得第二秘钥的明文;Decoding the ciphertext of the second secret key according to the plaintext of the first secret key to obtain the plaintext of the second secret key;
根据所述第二秘钥的明文对所述第三秘钥的密文进行解码,获得第三秘钥的明文。Decoding the ciphertext of the third key according to the plaintext of the second key to obtain the plaintext of the third key.
可选的,所述注册中心对所述身份认证信息的验证方式为:Optionally, the verification method of the registration center for the identity authentication information is:
根据所述第三秘钥的明文对所述身份认证信息进行解密,获得所述第二秘钥的明文、所述第一时间戳和所述消费方的微服务标识;Decrypt the identity authentication information according to the plaintext of the third secret key, and obtain the plaintext of the second secret key, the first timestamp and the microservice identifier of the consumer;
获取解密时的第二时间戳;Obtain the second timestamp when decrypting;
对所述第二秘钥的明文和所述消费方的微服务标识的合法性进行验证;Verifying the legitimacy of the plaintext of the second secret key and the microservice identifier of the consumer;
根据所述第二时间戳和所述第一时间戳进行时效性验证。Perform timeliness verification according to the second timestamp and the first timestamp.
可选的,所述服务发现响应结果还包括提供方接口及访问权限开关状态;微服务实例调用模块440,具体用于:Optionally, the service discovery response result also includes the provider interface and the status of the access right switch; the microservice instance invokes the
若所述访问权限开关状态为打开状态,则获取具有访问权限的接口;If the state of the access right switch is on, then obtain the interface with the access right;
根据所述提供方地址与所述提供方建立连接,并通过具有访问权限的接口调用所述提供方的微服务实例。A connection is established with the provider according to the address of the provider, and a microservice instance of the provider is invoked through an interface with access authority.
可选的,所述服务发现响应结果还包括灰度控制器地址及灰度开关状态,微服务实例调用模块440,具体用于:Optionally, the service discovery response result also includes the address of the grayscale controller and the state of the grayscale switch, and the microservice instance invokes the
若所述灰度开关状态为打开状态,则根据所述灰度控制器地址从灰度控制器中获取灰度版本信息;If the state of the grayscale switch is on, then obtain the grayscale version information from the grayscale controller according to the address of the grayscale controller;
根据所述服务发现响应结果调用所述灰度版本信息对应的微服务实例。Invoking the microservice instance corresponding to the grayscale version information according to the service discovery response result.
可选的,微服务实例调用模块440,具体用于:Optionally, the microservice instance invokes
若所述灰度开关状态为关闭状态,且所述调用提供方的微服务实例包含两个或两个以上的版本,则基于负载均衡原理调用所述提供方的两个或两个以上的版本的微服务实例。If the state of the grayscale switch is off, and the microservice instance of the calling provider contains two or more versions, call two or more versions of the provider based on the principle of load balancing microservice instance.
上述装置可执行本发明前述所有实施例所提供的方法,具备执行上述方法相应的功能模块和有益效果。未在本实施例中详尽描述的技术细节,可参见本发明前述所有实施例所提供的方法。The above-mentioned device can execute the methods provided by all the foregoing embodiments of the present invention, and has corresponding functional modules and advantageous effects for executing the above-mentioned methods. For technical details not described in detail in this embodiment, reference may be made to the methods provided in all the foregoing embodiments of the present invention.
实施例四Embodiment Four
图5是根据本发明实施例四提供的一种电子设备的结构示意图。电子设备10旨在表示各种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示各种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备(如头盔、眼镜、手表等)和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本发明的实现。FIG. 5 is a schematic structural diagram of an electronic device according to Embodiment 4 of the present invention.
如图5所示,电子设备10包括至少一个处理器11,以及与至少一个处理器11通信连接的存储器,如只读存储器(ROM)12、随机访问存储器(RAM)13等,其中,存储器存储有可被至少一个处理器执行的计算机程序,处理器11可以根据存储在只读存储器(ROM)12中的计算机程序或者从存储单元18加载到随机访问存储器(RAM)13中的计算机程序,来执行各种适当的动作和处理。在RAM 13中,还可存储电子设备10操作所需的各种程序和数据。处理器11、ROM 12以及RAM 13通过总线14彼此相连。输入/输出(I/O)接口15也连接至总线14。As shown in FIG. 5 , the
电子设备10中的多个部件连接至I/O接口15,包括:输入单元16,例如键盘、鼠标等;输出单元17,例如各种类型的显示器、扬声器等;存储单元18,例如磁盘、光盘等;以及通信单元19,例如网卡、调制解调器、无线通信收发机等。通信单元19允许电子设备10通过诸如因特网的计算机网络和/或各种电信网络与其他设备交换信息/数据。Multiple components in the
处理器11可以是各种具有处理和计算能力的通用和/或专用处理组件。处理器11的一些示例包括但不限于中央处理单元(CPU)、图形处理单元(GPU)、各种专用的人工智能(AI)计算芯片、各种运行机器学习模型算法的处理器、数字信号处理器(DSP)、以及任何适当的处理器、控制器、微控制器等。处理器11执行上文所描述的各个方法和处理,例如微服务的调用方法。
在一些实施例中,微服务的调用方法可被实现为计算机程序,其被有形地包含于计算机可读存储介质,例如存储单元18。在一些实施例中,计算机程序的部分或者全部可以经由ROM 12和/或通信单元19而被载入和/或安装到电子设备10上。当计算机程序加载到RAM 13并由处理器11执行时,可以执行上文描述的微服务的调用方法的一个或多个步骤。备选地,在其他实施例中,处理器11可以通过其他任何适当的方式(例如,借助于固件)而被配置为执行微服务的调用方法。In some embodiments, the calling method of the microservice can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the
本文中以上描述的系统和技术的各种实施方式可以在数字电子电路系统、集成电路系统、场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、芯片上系统的系统(SOC)、负载可编程逻辑设备(CPLD)、计算机硬件、固件、软件、和/或它们的组合中实现。这些各种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips Implemented in a system of systems (SOC), load programmable logic device (CPLD), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include being implemented in one or more computer programs executable and/or interpreted on a programmable system including at least one programmable processor, the programmable processor Can be special-purpose or general-purpose programmable processor, can receive data and instruction from storage system, at least one input device, and at least one output device, and transmit data and instruction to this storage system, this at least one input device, and this at least one output device an output device.
用于实施本发明的方法的计算机程序可以采用一个或多个编程语言的任何组合来编写。这些计算机程序可以提供给通用计算机、专用计算机或其他可编程数据处理装置的处理器,使得计算机程序当由处理器执行时使流程图和/或框图中所规定的功能/操作被实施。计算机程序可以完全在机器上执行、部分地在机器上执行,作为独立软件包部分地在机器上执行且部分地在远程机器上执行或完全在远程机器或服务器上执行。Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus, so that the computer program causes the functions/operations specified in the flowcharts and/or block diagrams to be implemented when executed by the processor. A computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
在本发明的上下文中,计算机可读存储介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的计算机程序。计算机可读存储介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。备选地,计算机可读存储介质可以是机器可读信号介质。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of the present invention, a computer readable storage medium may be a tangible medium which may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus or device. A computer readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, a computer readable storage medium may be a machine readable signal medium. More specific examples of machine-readable storage media would include one or more wire-based electrical connections, portable computer disks, hard disks, Random Access Memory (RAM), Read Only Memory (ROM), Erasable Programmable Read Only Memory (EPROM or flash memory), optical fiber, compact disk read only memory (CD-ROM), optical storage, magnetic storage, or any suitable combination of the foregoing.
为了提供与用户的交互,可以在电子设备上实施此处描述的系统和技术,该电子设备具有:用于向用户显示信息的显示装置(例如,CRT(阴极射线管)或者LCD(液晶显示器)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给电子设备。其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。In order to provide interaction with the user, the systems and techniques described herein can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display)) for displaying information to the user. monitor); and a keyboard and pointing device (eg, a mouse or a trackball) through which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and can be in any form (including Acoustic input, speech input or, tactile input) to receive input from the user.
可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。通信网络的示例包括:局域网(LAN)、广域网(WAN)、区块链网络和互联网。The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., as a a user computer having a graphical user interface or web browser through which a user can interact with embodiments of the systems and techniques described herein), or including such backend components, middleware components, Or any combination of front-end components in a computing system. The components of the system can be interconnected by any form or medium of digital data communication, eg, a communication network. Examples of communication networks include: local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
计算系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。服务器可以是云服务器,又称为云计算服务器或云主机,是云计算服务体系中的一项主机产品,以解决了传统物理主机与VPS服务中,存在的管理难度大,业务扩展性弱的缺陷。A computing system can include clients and servers. Clients and servers are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also known as a cloud computing server or a cloud host. It is a host product in the cloud computing service system to solve the problems of difficult management and weak business expansion in traditional physical hosts and VPS services. defect.
应该理解,可以使用上面所示的各种形式的流程,重新排序、增加或删除步骤。例如,本发明中记载的各步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本发明的技术方案所期望的结果,本文在此不进行限制。It should be understood that steps may be reordered, added or deleted using the various forms of flow shown above. For example, each step described in the present invention may be executed in parallel, sequentially, or in a different order, as long as the desired result of the technical solution of the present invention can be achieved, there is no limitation herein.
上述具体实施方式,并不构成对本发明保护范围的限制。本领域技术人员应该明白的是,根据设计要求和其他因素,可以进行各种修改、组合、子组合和替代。任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明保护范围之内。The above specific implementation methods do not constitute a limitation to the protection scope of the present invention. It should be apparent to those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made depending on design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211659070.9A CN115801286A (en) | 2022-12-22 | 2022-12-22 | Calling method, device, equipment and storage medium of microservice |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211659070.9A CN115801286A (en) | 2022-12-22 | 2022-12-22 | Calling method, device, equipment and storage medium of microservice |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN115801286A true CN115801286A (en) | 2023-03-14 |
Family
ID=85426417
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202211659070.9A Pending CN115801286A (en) | 2022-12-22 | 2022-12-22 | Calling method, device, equipment and storage medium of microservice |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN115801286A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN120201078A (en) * | 2025-05-26 | 2025-06-24 | 深圳市雁联计算系统有限公司 | A method, device, electronic device and storage medium for calling microservices |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110224998A (en) * | 2019-05-20 | 2019-09-10 | 平安普惠企业管理有限公司 | A kind of micro services register method and device |
| CN110224855A (en) * | 2019-05-13 | 2019-09-10 | 平安科技(深圳)有限公司 | Register method, device, computer equipment and the storage medium of micro services example |
| CN115237808A (en) * | 2022-08-15 | 2022-10-25 | 中国工商银行股份有限公司 | Software online test method, device and system |
-
2022
- 2022-12-22 CN CN202211659070.9A patent/CN115801286A/en active Pending
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110224855A (en) * | 2019-05-13 | 2019-09-10 | 平安科技(深圳)有限公司 | Register method, device, computer equipment and the storage medium of micro services example |
| CN110224998A (en) * | 2019-05-20 | 2019-09-10 | 平安普惠企业管理有限公司 | A kind of micro services register method and device |
| CN115237808A (en) * | 2022-08-15 | 2022-10-25 | 中国工商银行股份有限公司 | Software online test method, device and system |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN120201078A (en) * | 2025-05-26 | 2025-06-24 | 深圳市雁联计算系统有限公司 | A method, device, electronic device and storage medium for calling microservices |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11665000B2 (en) | Method and apparatus for processing privacy data of block chain, device, and storage medium | |
| WO2022206349A1 (en) | Information verification method, related apparatus, device, and storage medium | |
| US10491399B2 (en) | Cryptographic method for secure communications | |
| EP3921991A1 (en) | System and method for hardening security between web services using protected forwarded access tokens | |
| WO2022247359A1 (en) | Cluster access method and apparatus, electronic device, and medium | |
| WO2025236608A1 (en) | Information verification method and related device | |
| US20160197887A1 (en) | Method of multi-factor authenication during encrypted communications | |
| US11509469B2 (en) | Methods and systems for password recovery based on user location | |
| US20220394039A1 (en) | Seamlessly securing access to application programming interface gateways | |
| CN113448545A (en) | Method, apparatus, storage medium, and program product for machine learning model servitization | |
| CN116011590A (en) | Federated learning method, device and system | |
| CN119808042A (en) | Container access control method, device, equipment and storage medium | |
| US12158939B1 (en) | Authentication artifact generation using single sign-on | |
| CN114861207B (en) | Data processing method, device, electronic device and computer readable storage medium | |
| CN116248368A (en) | Identity authentication method, system, equipment and storage medium based on block chain | |
| CN115801286A (en) | Calling method, device, equipment and storage medium of microservice | |
| CN119416204B (en) | Data migration method, device, equipment, medium and product based on trusted execution environment in trusted data space | |
| CN117370954A (en) | Password resource pool management method, device, equipment and storage medium | |
| CN112565156A (en) | Information registration method, device and system | |
| CN113609156B (en) | Data query and write method and device, electronic equipment and readable storage medium | |
| CN115801237A (en) | Information encryption/decryption device, information encryption method, and information decryption method | |
| CN114969711A (en) | Security authentication method, electronic device and storage medium | |
| CN120017255B (en) | Key generation method and electronic equipment | |
| US12432048B2 (en) | Agentless single sign-on techniques | |
| CN120151020B (en) | Data transmission method, apparatus, device, storage medium and program product |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |