Service contract change detection method and device, storage medium and processor
By receiving the referenced version and verification information of the service consumer, combined with the operating version and compatibility information of the contract management platform, the service contract changes of the service provider are solved, and the service consumer is unable to actively perceive the contract changes of the service provider, and achieves rapid and accurate detection and timely upgrades.
Patent Information
- Application Number
- CN202411619508.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-13
AI Technical Summary
In the microservice architecture, service consumers cannot actively perceive the service contract changes of the service provider, resulting in abnormal functions. The existing technology detects changes by maintaining the service contract documents, but the update is not timely or the document is inconsistent with the actual situation, resulting in inaccurate detection.
By receiving the reference version and verification information of the service contract component sent by the service consumer, obtain the running version and compatibility information of the service contract component maintained in the contract management platform, perform version comparison, compatibility detection and content verification, and determine whether the service provider has changed the service contract.
It realizes rapid and accurate detection of service contract changes in the service provider, reduces the error rate of determining the scope of impact, ensures timely discovering microservices that need to be upgraded and synchronously upgraded.
Smart Images

Figure CN119583348A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a service contract change detection method, device, storage medium and processor. Background Art
[0002] Microservice architecture is one of the most popular application architectures. Under the microservice architecture, the traditional monolithic application is split to form multiple microservice applications that are usually bounded by business domains. A system using microservice architecture is a distributed system. When the service contract of the service provider of the distributed system changes, the service consumer corresponding to the service provider cannot actively perceive the change of the service contract of the service provider. If the service consumer does not follow the service provider to upgrade synchronously, it is very easy to cause functional abnormalities in the distributed system.
[0003] Currently, service contract documents that maintain the calling relationships between services are mainly used to detect service contract changes on the service provider side, and then determine the service consumers that need to upgrade their service contracts. However, if the calling relationships between services are recorded in service contract documents, and the documents are not updated in a timely manner, or the maintained service contract documents are inconsistent with the actual operation, the service provider's service contract change detection will be inaccurate, affecting the subsequent judgment of the impact scope of the service contract changes, and the affected service consumers cannot be upgraded synchronously in a timely manner. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a service contract change detection method, device, storage medium, processor and computer program product.
[0005] In order to achieve the above objectives, the present application provides a service contract change detection method in a first aspect, comprising:
[0006] After any service consumer references a service contract component of any service provider, receiving a reference version and first verification information of the service contract component sent by the service consumer;
[0007] Obtaining the running version of the service contract component maintained in the contract management platform, first compatibility information of the referenced version, and second verification information and second compatibility information of the running version;
[0008] Compare the reference version and the running version to obtain a first detection result of whether the reference version and the running version are consistent;
[0009] Determining, based on the referenced version and the second compatibility information, whether the running version is compatible with the second detection result of the referenced version; and / or
[0010] A third detection result of determining whether the contents of the service contract component of the running version are consistent with the contract component of the referenced version according to the first verification information and the second verification information;
[0011] It is determined whether a service contract change occurs to the service provider according to the first detection result and at least one of the second detection result and the third detection result.
[0012] In an embodiment of the present application, the third detection result of determining whether the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version based on the first verification information and the second verification information includes: comparing the first verification information and the second verification information; when the first verification information and the second verification information are consistent, determining that the third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version; when the first verification information and the second verification information are inconsistent, determining that the third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the referenced version.
[0013] In an embodiment of the present application, it is determined that no service contract change has occurred on the service provider when all of the following conditions are met: the first detection result is that the reference version and the running version are inconsistent; the second detection result is that the running version is compatible with the reference version; the third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the reference version.
[0014] In an embodiment of the present application, it is determined that no service contract change has occurred on the service provider when all of the following conditions are met: the first detection result is that the reference version and the running version are consistent; the third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the reference version.
[0015] In an embodiment of the present application, it is determined that a service contract change has occurred on the service provider when all of the following conditions are met: the first detection result is that the reference version and the running version are inconsistent; the second detection result is that the running version is incompatible with the reference version.
[0016] In an embodiment of the present application, it is determined that a service contract change has occurred on the service provider side when all of the following conditions are met: the first detection result is that the reference version and the running version are inconsistent; the second detection result is that the running version is compatible with the reference version; the third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the reference version.
[0017] In an embodiment of the present application, it is determined that a service contract change has occurred on the service provider when all of the following conditions are met: the first detection result is that the reference version and the running version are consistent; the third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the reference version.
[0018] In the embodiment of the present application, the method further includes: in the case of determining that a service provider has a service contract change, triggering an alarm to prompt the user terminal to determine the impact scope of the service provider's service contract change.
[0019] In the embodiment of the present application, the service contract component is referenced by the service consumer from the central warehouse, and the service contract component is constructed by the service provider based on the entity class of the service contract request and return parameters, and published to the central warehouse.
[0020] A second aspect of the present application provides a service contract change detection device, comprising:
[0021] An information receiving module, used for receiving a reference version and first verification information of the service contract component sent by any service consumer after any service consumer references the service contract component of any service provider;
[0022] An information acquisition module, used to acquire the running version of the service contract component maintained in the contract management platform, the first compatibility information of the referenced version, and the second verification information and second compatibility information of the running version;
[0023] A version detection module, used for comparing the reference version and the running version to obtain a first detection result of whether the reference version and the running version are consistent;
[0024] A compatibility detection module, configured to determine whether the running version is compatible with the second detection result of the referenced version according to the first compatibility information and the second compatibility information; and / or
[0025] A verification information detection module, used to determine a third detection result of whether the contents of the service contract component of the running version are consistent with the contract component of the referenced version according to the first verification information and the second verification information;
[0026] The contract change detection module is used to determine whether a service contract change occurs to the service provider based on the first detection result and at least one of the second detection result and the third detection result.
[0027] A third aspect of the present application provides a processor configured to execute the above-mentioned service contract change detection method.
[0028] A fourth aspect of the present application provides a machine-readable storage medium having instructions stored thereon, which, when executed by a processor, configures the processor to execute the above-mentioned service contract change detection method.
[0029] A fifth aspect of the present application provides a computer program product, including a computer program, which implements the above-mentioned service contract change detection method when executed by a processor.
[0030] Through the above technical solution, it is possible to detect whether the versions of the service contract components of the service consumer and the service provider are consistent, whether the contents of the service contract components are consistent, and whether the versions of the service contract components are compatible, so as to avoid the detection results of service contract changes being affected by inconsistent or incompatible service contracts. It is possible to quickly and accurately detect whether the service provider has made a service contract change, thereby reducing the error rate in subsequent determination of the impact scope of the service contract change, which is conducive to the subsequent timely discovery of microservices that need to upgrade the service contract and upgrade them synchronously.
[0031] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:
[0033] Figure 1 A schematic diagram of an application environment of a service contract change detection method according to an embodiment of the present application is schematically shown;
[0034] Figure 2 The following is a schematic diagram showing a flow chart of a service contract change detection method according to an embodiment of the present application;
[0035] Figure 3 The following schematically shows a flow chart of a service provider publishing a service contract component according to an embodiment of the present application;
[0036] Figure 4 A schematic diagram of a contract management platform according to an embodiment of the present application is schematically shown;
[0037] Figure 5 A schematic diagram of a process for calculating verification information according to an embodiment of the present application is shown;
[0038] Figure 6 A schematic diagram schematically shows a service provider updating a service contract component version according to an embodiment of the present application;
[0039] Figure 7 A schematic diagram of a process flow of another service contract change detection method according to an embodiment of the present application is shown;
[0040] Figure 8 A timing diagram of a service contract change detection method according to an embodiment of the present application is schematically shown;
[0041] Fig. 9The structure block diagram of the service contract change detection device according to the embodiment of the present application is schematically shown;
[0042] Fig.10 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0044] It should be noted that if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0045] The acquisition, transmission, storage, use, and processing of data in the technical solution of this application are in compliance with the relevant provisions of national laws and regulations. In addition, it should be noted that in the embodiments of this application, some existing solutions in the industry such as certain software, components, and models may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of this application, but it does not mean that the applicant has or will necessarily use the solution.
[0046] The service contract change detection method provided in this application can be applied to Figure 1 In the application environment shown. The contract management platform 101 communicates with the service provider 102 and the service consumer 103 respectively. The contract management platform 101 can obtain the version information of the corresponding contract component from the service provider 102. The contract management platform 101 maintains the running version of the service contract component corresponding to the service provider 102, which is sent to the contract management platform 101 by the service consumer 103. The service provider 102 can publish its service contract component to the central warehouse 104, and the service consumer 103 can reference the service contract component of the service provider 102 from the central warehouse 104.
[0047] Figure 2 The following schematically shows a flow chart of a method for detecting service contract changes according to an embodiment of the present application. Figure 2 As shown, in one embodiment of the present application, a service contract change detection method is provided. This embodiment mainly applies this method to the above Figure 1 Taking the contract management platform 101 in FIG. 1 as an example, the following steps are included:
[0048] Step 202: After any service consumer references the service contract component of any service provider, receive the reference version and first verification information of the service contract component sent by the service consumer.
[0049] Step 204: Obtain the running version of the service contract component maintained in the contract management platform, the first compatibility information of the referenced version, and the second verification information and second compatibility information of the running version.
[0050] A microservice application cluster includes multiple microservice applications, each of which usually includes a service provider and a service consumer. A service provider can correspond to at least one service consumer. A service provider is a service that provides an interface for other services to call. A service consumer is a service that calls the interface provided by the service provider. The service contract component of the service provider includes the entity class of the request and return parameters of the service contract of the service provider.
[0051] In the embodiment of the present application, the service contract component is referenced by the service consumer from the central warehouse, and the service contract component is constructed by the service provider based on the entity class of the service contract request and return parameters, and published to the central warehouse.
[0052] Before any service consumer references any service provider's service contract component, the service provider's service contract component needs to be published first. The service provider can extract the entity class of the service contract request and return parameters, compile and build it, and obtain a jar package including the entity class of the service contract request and return parameters, which is its service contract component. After that, the service provider publishes its service contract component to the central warehouse.
[0053] like Figure 3As shown, a flow chart of a service provider publishing a service contract component is provided. Among them, the service provider (service A in the figure) includes a controller layer module, a business layer module and a database layer module. Among them, the controller layer module can interact with the application front end, receive the request of the service consumer (service B in the figure), and can extract the entity class related to the request return parameter to the contract module based on the request. By compiling and building the contract module, a jar package including the request and request return parameter entity class is obtained, that is, the service A contract component. The service provider publishes its service A contract component to the central warehouse (maven in the figure). The service consumer can send a call or import request, and the call or import request carries the name and version of the service A contract component and the organization ID, etc. Based on the call or import request, the service A contract component can be introduced in the central warehouse. The controller layer module calls the business layer module, and the business layer module is used to implement specific business logic. The business layer module calls the database layer module, and the database layer module is used to implement the logic of interacting with the database.
[0054] The central repository also maintains reference information and version information of the service contract component. The reference information may include the identifier (groupId) of the project organization or team, and the identifier (artifactId) of the project or module. The version information may include the version number of the service contract component. The service consumer may reference the service contract component of the service provider from the central repository. The central repository may be various project management and build tools, such as maven and gradle.
[0055] The above solution abstracts the service contract component through the service provider and publishes it to the central warehouse. After that, the service consumer can connect with the service provider by introducing the contract component. This makes it unnecessary for the service consumer to repeatedly build the service contract structure when calling the service provider, greatly reducing the possibility of complex contract construction errors.
[0056] The contract management platform can manage the service contract components of the service provider. The contract management platform maintains information about the service contract components, including but not limited to reference information, version information, compatibility between different versions, and verification information of the service contract components. For example, Figure 4 As shown, a schematic diagram of a contract management platform is provided. The contract management platform (the service contract central management platform in the figure) maintains service A contract component information, service B contract component information, and information on service contract components of other service providers. The service A contract component information includes reference information, version number, verification information, and compatibility of each version.
[0057] The reference information of the service A contract component includes the identifier of the project organization or team (groupId in the diagram), and the identifier of the project or module (artifactId in the diagram). When using Maven, the version number of the service A contract component corresponds to the version field referenced by Maven. The compatibility of each version is used to characterize the compatibility of the new version of the service contract component with the old version. For example, in the diagram, the v1.1 version of the service A contract component is compatible with the v1.0 version of the service A contract component, and the v1.5 version of the service A contract component is incompatible with the v1.0 and v1.1 versions of the service A contract component, but is compatible with the v1.4 version of the service A contract component.
[0058] If the new version of the service contract component is compatible with the old version, the service consumer does not need to upgrade. If the new version of the service contract component is not compatible with the old version, the service consumer needs to upgrade. For example, if the service provider adds a new interface, the corresponding service contract adds the entity class of the request and return parameters of the new interface, but the service consumer does not call this new interface. At this time, the service consumer does not need to upgrade, and the new version of the service contract component is compatible with the old version. If the service provider changes the name, structure, and type of the request or return parameters of the old interface, the service consumer needs to upgrade, otherwise the interface call will be abnormal and the new version of the service contract is incompatible with the old version.
[0059] After the service contract component is published to the central warehouse, the identifier of the organization or team to which the service contract component belongs, the identifier of the project or module, and the version number can be set. If the service provider publishes the service contract component but does not update the version number, when the service consumer references it, it will still think that it is referencing the latest version of the service contract component, but the content has changed. At this time, an exception may occur when calling the interface. Therefore, in order to avoid the situation where the service contract component has the same version but different content, the verification information of the service contract component can be maintained in the contract management platform, and the content consistency of the same version of the service contract component can be ensured by the verification information. Each version of the service contract component corresponds to verification information. The verification information can be calculated based on MD5.
[0060] For example, Figure 5As shown, a flow chart for calculating verification information is provided. The contract management platform (i.e., the service contract central management platform in the figure) maintains information about the service A contract component, which includes the version number, verification information, and reference information (not shown in the figure) of the service A contract component. The version number may include multiple iteratively updated versions, such as the initial version V1.0 to the latest version V1.5. When calculating the verification information of version V1.5, the verification information automatic calculation module of the contract management platform can obtain the reference information and version information of the service A contract component. The verification information automatic calculation module can obtain the corresponding jar package from the central warehouse based on the reference information and version information of the service A contract component, and perform MD5 calculation on the obtained jar package to obtain the MD5 value. The MD5 value is the verification information of the V1.5 version of the service A contract component.
[0061] After referencing the service contract component of the service provider, the service consumer may send the referenced version and first verification information of the referenced service contract component to the contract management platform. The contract management platform may receive the referenced version and first verification information of the service contract component. Among them, the first verification information may be obtained through MD5 calculation. The contract management platform may obtain the running version of the service contract component it maintains, the first compatibility information of the referenced version, and the second verification information and second compatibility information of the running version. Among them, the running version of the service contract component refers to the version of the service contract component actually currently run by the service provider, which is generally the latest version of the service contract component. The second verification information may be obtained through MD5 calculation by the contract management platform.
[0062] The service provider can interact with the contract management platform through heartbeat detection. The service provider can obtain the version information of its service contract component and send the version information to the contract management platform to update the version identifier of the corresponding service contract component in the contract management platform. The version identifier can be used to represent the version number of the service contract component actually running by the service provider in the current microservice cluster. For example, Figure 6 As shown, a schematic diagram of a service provider updating a service contract component version is provided. In the diagram, service provider A can obtain its own contract component version information and update the running version mark of the corresponding contract component information in the service contract central management platform, that is, the version number of the service A contract component information.
[0063] Step 206: Compare the reference version and the running version to obtain a first detection result of whether the reference version and the running version are consistent.
[0064] The contract management platform can compare the reference version and the running version to determine whether the reference version and the running version of the service contract component are consistent. If the reference version is different from the running version, the first detection result is version inconsistency. At this time, it can be explained that the service provider has updated and released a new version of the service contract component, but there is still a situation where the running version and the reference version are compatible or incompatible. If the reference version is the same as the running version, the first detection result is version consistency. At this time, although the version of the service contract component of the service provider has not changed, the content of the service contract component may change or may not change.
[0065] Step 208: Determine the second detection result of whether the running version is compatible with the referenced version according to the referenced version and the second compatibility information.
[0066] The contract management platform can determine the second detection result of whether the running version is compatible with the reference version based on the first compatibility information and the second compatibility information. For example, the contract management platform can traverse the second compatibility information to find a version that is compatible with the running version of the service contract component, and then detect whether the reference version of the service contract component exists in the found compatible version. If the reference version of the service contract component exists in the found compatible version, the second detection result is that the running version is compatible with the reference version. If the reference version of the service contract component does not exist in the found compatible version, the second detection result is that the running version is not compatible with the reference version.
[0067] Step 210: Determine a third detection result of whether the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version based on the first verification information and the second verification information.
[0068] The contract management platform can determine the third detection result of whether the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version based on the first verification information and the second verification information. Among them, the third detection result can be that the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version, or it can be that the content of the service contract component of the running version is inconsistent with the content of the contract component of the referenced version.
[0069] In an embodiment of the present application, the third detection result of determining whether the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version based on the first verification information and the second verification information includes: comparing the first verification information and the second verification information; when the first verification information and the second verification information are consistent, determining that the third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version; when the first verification information and the second verification information are inconsistent, determining that the third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the referenced version.
[0070] The contract management platform can compare the first verification information with the second verification information. If the first verification information and the second verification information are inconsistent, the third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the referenced version. If the first verification information and the second verification information are consistent, the third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version.
[0071] Step 212: Determine whether a service contract change occurs with the service provider based on the first detection result and at least one of the second detection result and the third detection result.
[0072] The contract management platform may determine whether a service contract change occurs with the service provider based on the first detection result and at least one of the second detection result and the third detection result.
[0073] In an embodiment of the present application, it is determined that no service contract change has occurred on the service provider when all of the following conditions are met: the first detection result is that the reference version and the running version are inconsistent; the second detection result is that the running version is compatible with the reference version; the third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the reference version.
[0074] If the contract management platform determines that the first test result is that the reference version and the running version are inconsistent, it may mean that the service provider has updated and released a new version of the service contract component, but there is still a situation where the running version and the reference version are compatible or incompatible. At this time, it is necessary to make a judgment in combination with the second test result. If the second test result is that the running version is compatible with the reference version, in order to avoid the situation where the content of the reference version with the same version number as the running version changes, but the version number of the reference version remains unchanged, the consistency of the content of the running version and the reference version is further ensured. If the third test result is that the content of the service contract component of the running version is consistent with the content of the contract component of the reference version, it can be determined that the service provider has not made any changes to the service contract.
[0075] The above scheme, when the running version is inconsistent with the reference version, combines the compatibility of the running version and the verification information of the running version and the reference version to determine whether the service contract of the service provider has changed, thereby ensuring the content consistency of different versions of compatible service contract components and avoiding the impact of different versions of compatible service contract components on the detection results of service contract changes.
[0076] In an embodiment of the present application, it is determined that no service contract change has occurred on the service provider when all of the following conditions are met: the first detection result is that the reference version and the running version are consistent; the third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the reference version.
[0077] If the contract management platform determines that the first test result is that the reference version and the running version are consistent, at this time, although the version of the service contract component of the service provider has not changed, the content of the service contract component may or may not change. At this time, it is necessary to make a judgment based on the third test result. If the third test result shows that the content of the service contract component of the running version is consistent with the content of the contract component of the reference version, it can be determined that the service provider has not changed the service contract.
[0078] In the above scheme, when the running version is consistent with the reference version, the verification information of the running version and the reference version is combined to determine whether the service contract of the service provider has changed, thereby ensuring the content consistency of the service contract components of the same version, and avoiding the detection result of the service contract change being affected by the inconsistency of the content of the service contract components of the same version.
[0079] In an embodiment of the present application, it is determined that a service contract change has occurred on the service provider when all of the following conditions are met: the first detection result is that the reference version and the running version are inconsistent; the second detection result is that the running version is incompatible with the reference version.
[0080] If the contract management platform determines that the first test result is that the reference version and the running version are inconsistent, it can be said that the service provider has updated and released a new version of the service contract component, but there is still a situation where the running version and the reference version are compatible or incompatible. At this time, it is necessary to make a judgment based on the second test result. If the second test result is that the running version is incompatible with the reference version, it can be determined that the service provider has changed the service contract.
[0081] The above scheme, when the running version is inconsistent with the referenced version, combines the compatibility of the running version to determine whether the service provider's service contract has changed, ensures the compatibility of different versions of service contract components, and avoids the detection result of service contract changes being affected by the incompatibility of different versions of service contract components.
[0082] In an embodiment of the present application, it is determined that a service contract change has occurred on the service provider side when all of the following conditions are met: the first detection result is that the reference version and the running version are inconsistent; the second detection result is that the running version is compatible with the reference version; the third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the reference version.
[0083] If the contract management platform determines that the first test result is that the reference version and the running version are inconsistent, it can be explained that the service provider has updated and released a new version of the service contract component, but there is still a situation where the running version and the reference version are compatible or incompatible. At this time, it is necessary to make a judgment in combination with the second test result. If the second test result is that the running version is compatible with the reference version, in order to avoid the situation where the content of the reference version with the same version number as the running version is changed, but the version number of the reference version remains unchanged, the consistency of the content of the running version and the reference version is further ensured. If the third test result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the reference version, it can be determined that the service provider has changed the service contract.
[0084] The above scheme, when the running version is inconsistent with the reference version, combines the compatibility of the running version and the verification information of the running version and the reference version to determine whether the service contract of the service provider has changed, thereby ensuring the content consistency of different versions of compatible service contract components and avoiding the impact of different versions of compatible service contract components on the detection results of service contract changes.
[0085] In an embodiment of the present application, it is determined that a service contract change has occurred on the service provider when all of the following conditions are met: the first detection result is that the reference version and the running version are consistent; the third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the reference version.
[0086] If the contract management platform determines that the first test result is that the reference version and the running version are consistent, at this time, although the version of the service contract component of the service provider has not changed, the content of the service contract component may or may not change. At this time, it is necessary to make a judgment in combination with the third test result. If the third test result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the reference version, it can be determined that the version of the service contract component is the same but the content has changed. At this time, the contract management platform can determine that the service provider has changed the service contract.
[0087] In the above scheme, when the running version is consistent with the reference version, the verification information of the running version and the reference version is combined to determine whether the service contract of the service provider has changed, thereby ensuring the content consistency of the service contract components of the same version, and avoiding the detection result of the service contract change being affected by the inconsistency of the content of the service contract components of the same version.
[0088] In the embodiment of the present application, the method further includes: in the case of determining that a service provider has a service contract change, triggering an alarm to prompt the user terminal to determine the impact scope of the service provider's service contract change.
[0089] When it is determined that the service provider has changed the service contract, the contract management platform can trigger an alarm to prompt the user terminal to determine the impact scope of the service provider's service contract change. The impact scope of the service provider's service contract change refers to the service consumers affected by the change of the service provider's service contract component.
[0090] The above scheme can promptly issue an alarm when it is determined that the service contract of the service provider has changed, thereby being able to promptly determine the impact scope of the change in the service provider's service contract, allowing the service consumer to synchronously upgrade the service contract in a timely manner, and ensuring the normal operation of the distributed system where the service provider and service consumer are located.
[0091] like Figure 7 As shown, a flowchart of another service contract change detection method is provided.
[0092] The service consumer sends the referenced contract component version number and verification information to the service contract central management platform. The service contract central management platform can determine whether the version number of the contract component referenced by the service consumer is consistent with the version number of the service contract component actually run by the service provider. If the version numbers are consistent, it can be determined whether the verification information of the referenced contract component version is consistent with the verification information of the service contract component actually run by the service provider. If the verification information is consistent, it is determined that the service provider has not made any service contract changes, and an alarm is triggered. If the verification information is inconsistent, it is determined that the service provider has not made any service contract changes, and an alarm is triggered.
[0093] If the version numbers are consistent, it is determined whether the version of the service contract component actually run by the service provider is compatible with the version of the referenced contract component. If the versions are incompatible, it is determined that the service provider has not made any service contract changes, and an alarm is triggered. If the versions are compatible, it is determined whether the verification information of the version of the referenced contract component is consistent with the verification information of the version of the service contract component actually run by the service provider. If the verification information is consistent, it is determined that the service provider has not made any service contract changes, and an alarm is triggered. If the verification information is inconsistent, it is determined that the service provider has not made any service contract changes, and an alarm is triggered.
[0094] like Figure 8 As shown, a timing diagram of a service contract change detection method is provided.
[0095] The service provider (service A) extracts the entity classes related to the service contract request return parameters, abstracts the entity classes related to the service contract request return parameters into a service contract module, compiles and builds the service contract module, and obtains a jar package containing the request and return parameter entity classes, namely the service A contract component. The service provider sets the reference information and version information of the service A contract component and publishes the service contract component to the central warehouse.
[0096] The service provider sends the reference information and version information of the service A contract component to the service contract central management platform. The service contract central management platform pulls the jar package of the service contract component from the central warehouse based on the reference information and version information of the service A contract component. The service contract central management platform performs MD5 calculation on the pulled jar, obtains the verification information corresponding to the version information of the service A contract component, and writes the verification information into the component information of the corresponding service A contract component.
[0097] The service consumer (service B) references the service A contract component from the central warehouse and sends the version information and verification information of the service A contract component to the service contract central management platform. The service provider sends the version information of the contract component actually running in the microservice cluster to the service contract central management platform. The service contract central management platform compares the version information of the contract component referenced by service B with the version information of the contract component actually running in the microservice cluster to see if they are consistent.
[0098] If the version information is consistent, the service contract central management platform compares the verification information of the version of the service A contract component referenced by the service consumer with the verification information of the same version recorded by the service contract central management platform. If the version information and verification information are consistent, the detection ends; if the version information is consistent but the verification information is inconsistent, service A updates the service contract component and triggers an alarm.
[0099] If the version information is inconsistent, the service contract central management platform detects whether the contract component version running in the current microservice cluster is compatible with the contract component version referenced by service B based on the version compatibility information of the service contract central management platform. If the version information is inconsistent, the versions are compatible, and the verification information is consistent, the detection ends; if the version information is inconsistent, the versions are compatible but the verification information is inconsistent, an alarm is triggered. If the version information is inconsistent and the versions are incompatible, an alarm is triggered and the detection ends.
[0100] Through the above technical solution, it is possible to detect whether the versions of the service contract components of the service consumer and the service provider are consistent, whether the contents of the service contract components are consistent, and whether the versions of the service contract components are compatible, so as to avoid the detection results of service contract changes being affected by inconsistent or incompatible service contracts. It is possible to quickly and accurately detect whether the service provider has made a service contract change, thereby reducing the error rate in subsequent determination of the impact scope of the service contract change, which is conducive to the subsequent timely discovery of microservices that need to upgrade the service contract and upgrade them synchronously.
[0101] Figure 2 and 6 FIG. 1 is a flow chart of a service contract change detection method in an embodiment. It should be understood that although Figure 2 and6 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 and 6 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0102] In one embodiment, Fig. 9 As shown, a service contract change detection device 900 is provided, including an information receiving module 902, an information acquisition module 904, a version detection module 906, a compatibility detection module 908, a verification information detection module 910 and a contract change detection module 912, wherein:
[0103] The information receiving module 902 is used to receive the reference version and first verification information of the service contract component sent by any service consumer after any service consumer references the service contract component of any service provider.
[0104] The information acquisition module 904 is used to obtain the running version of the service contract component maintained in the contract management platform, the first compatibility information of the referenced version, and the second verification information and second compatibility information of the running version.
[0105] The version detection module 906 is used to compare the reference version and the running version to obtain a first detection result of whether the reference version and the running version are consistent.
[0106] The compatibility detection module 908 is used to determine the second detection result of whether the running version is compatible with the referenced version according to the first compatibility information and the second compatibility information.
[0107] The verification information detection module 910 is used to determine a third detection result of whether the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version according to the first verification information and the second verification information.
[0108] The contract change detection module 912 is used to determine whether a service contract of the service provider has been changed according to the first detection result and at least one of the second detection result and the third detection result.
[0109] A microservice application cluster includes multiple microservice applications, each of which usually includes a service provider and a service consumer. A service provider can correspond to at least one service consumer. A service provider is a service that provides an interface for other services to call. A service consumer is a service that calls the interface provided by the service provider. The service contract component of the service provider includes the entity class of the request and return parameters of the service contract of the service provider.
[0110] After referencing the service contract component of the service provider, the service consumer may send the referenced version of the referenced service contract component and the first verification information to the information receiving module 902. The information receiving module 902 may receive the referenced version of the service contract component and the first verification information. The first verification information may be obtained by MD5 calculation.
[0111] The information acquisition module 904 can obtain the running version of the service contract component maintained by the contract management platform, the first compatibility information of the referenced version, and the second verification information and second compatibility information of the running version. Among them, the running version of the service contract component refers to the version of the service contract component currently actually run by the service provider, which is generally the latest version of the service contract component. The second verification information can be obtained by performing MD5 calculation on the contract management platform.
[0112] The version detection module 906 can compare the reference version and the running version to determine whether the reference version and the running version of the service contract component are consistent. If the reference version is different from the running version, the first detection result is that the versions are inconsistent. At this time, it can be explained that the service provider has changed the service contract, that is, the service contract component has changed. If the reference version is the same as the running version, the first detection result is that the versions are consistent. At this time, although the version of the service contract component of the service provider has not changed, the content of the service contract component may change or may not change.
[0113] The compatibility detection module 908 can determine the second detection result of whether the running version is compatible with the reference version based on the first compatibility information and the second compatibility information. For example, the compatibility detection module 908 can traverse the second compatibility information to find a version that is compatible with the running version of the service contract component, and then detect whether the reference version of the service contract component exists in the found compatible version. If the reference version of the service contract component exists in the found compatible version, the second detection result is that the running version is compatible with the reference version. If the reference version of the service contract component does not exist in the found compatible version, the second detection result is that the running version is not compatible with the reference version.
[0114] The verification information detection module 910 can determine the third detection result of whether the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version based on the first verification information and the second verification information. Among them, the third detection result can be that the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version, or it can be that the content of the service contract component of the running version is inconsistent with the content of the contract component of the referenced version. Specifically, the verification information detection module 910 can compare the first verification information and the second verification information. If the first verification information and the second verification information are inconsistent, the third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the referenced version. If the first verification information and the second verification information are consistent, the third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version.
[0115] The contract change detection module 912 can determine whether the service provider has a service contract change based on the first test result, and at least one of the second test result and the third test result. If the contract change detection module 912 determines that the first test result is that the reference version and the running version are inconsistent, it can be explained that the service provider has updated and released a new version of the service contract component, but there is still a situation where the running version and the reference version are compatible or incompatible. At this time, it is necessary to make a judgment in combination with the second test result. If the second test result is that the running version is compatible with the reference version, in order to avoid the situation where the content of the reference version with the same version number as the running version changes, but the version number of the reference version remains unchanged, it is also further ensured that the content of the running version is consistent with that of the reference version. If the third test result is that the content of the service contract component of the running version is consistent with the content of the contract component of the reference version, it can be determined that the service provider has not changed the service contract.
[0116] If the contract change detection module 912 determines that the first detection result is that the reference version and the running version are consistent, at this time, although the version of the service contract component of the service provider has not changed, the content of the service contract component may change or may not change. At this time, it is necessary to make a judgment in combination with the third detection result. If the third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the reference version, it can be determined that the service provider has not changed the service contract.
[0117] If the contract change detection module 912 determines that the first detection result is that the reference version and the running version are inconsistent, it can be explained that the service provider has updated and released a new version of the service contract component, but there is still a situation where the running version and the reference version are compatible or incompatible. At this time, it is necessary to make a judgment in combination with the second detection result. If the second detection result is that the running version is incompatible with the reference version, it can be determined that the service provider has a service contract change.
[0118] If the contract change detection module 912 determines that the first detection result is that the reference version and the running version are inconsistent, it can be explained that the service provider has updated and released a new version of the service contract component, but there is still a situation where the running version and the reference version are compatible or incompatible. At this time, it is necessary to make a judgment in combination with the second detection result. If the second detection result is that the running version is compatible with the reference version, in order to avoid the situation where the content of the reference version with the same version number as the running version is changed, but the version number of the reference version remains unchanged, the consistency of the content of the running version and the reference version is further ensured. If the third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the reference version, it can be determined that the service provider has a service contract change.
[0119] If the contract change detection module 912 determines that the first detection result is that the reference version and the running version are consistent, at this time, although the version of the service contract component of the service provider has not changed, the content of the service contract component may change or may not change. At this time, it is necessary to make a judgment in combination with the third detection result. If the third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the reference version, it can be determined that the version of the service contract component is the same but the content has changed. At this time, the contract change detection module 912 can determine that the service provider has a service contract change.
[0120] In one embodiment, the service contract change detection device 900 further includes an alarm module 914. The alarm module 914 is used for triggering an alarm on the contract management platform when determining that the service provider has a service contract change, so as to prompt the user terminal to determine the impact scope of the service provider's service contract change. The impact scope of the service provider's service contract change refers to the service consumers affected by the change of the service provider's service contract component.
[0121] Through the above technical solution, it is possible to detect whether the versions of the service contract components of the service consumer and the service provider are consistent, whether the contents of the service contract components are consistent, and whether the versions of the service contract components are compatible, so as to avoid the detection results of service contract changes being affected by inconsistent or incompatible service contracts. It is possible to quickly and accurately detect whether the service provider has made a service contract change, thereby reducing the error rate in subsequent determination of the impact scope of the service contract change, which is conducive to the subsequent timely discovery of microservices that need to upgrade the service contract and upgrade them synchronously.
[0122] The service contract change detection device 900 includes a processor and a memory. The above-mentioned information receiving module 902, information acquisition module 904, version detection module 906, compatibility detection module 908, verification information detection module 910, contract change detection module 912 and alarm module 914 are all stored in the memory as program units, and the processor executes the above-mentioned program modules stored in the memory to implement corresponding functions.
[0123] The processor includes a kernel, which calls the corresponding program unit from the memory. The kernel can be set to one or more, and the service contract change detection method is implemented by adjusting the kernel parameters.
[0124] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0125] An embodiment of the present application provides a storage medium on which a program is stored, and when the program is executed by a processor, the above-mentioned service contract change detection method is implemented.
[0126] An embodiment of the present application provides a processor, which is used to run a program, wherein the above-mentioned service contract change detection method is executed when the program is running.
[0127] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.10 As shown. The computer device includes a processor A01, a network interface A02, a memory (not shown in the figure) and a database (not shown in the figure) connected via a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02 and a database (not shown in the figure). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A04. The database of the computer device is used to store data such as service contract detection results. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program B02 is executed by the processor A01, a service contract change detection method is implemented.
[0128] Those skilled in the art will understand that Fig.10The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0129] An embodiment of the present application provides a device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the steps of the service contract change detection method are implemented.
[0130] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that initializes the steps of a service contract change detection method.
[0131] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0132] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0133] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0134] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0135] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0136] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0137] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0138] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0139] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A service contract change detection method, characterized in that: Applied to a contract management platform, the method includes: After any service consumer references a service contract component of any service provider, receiving a reference version and first verification information of the service contract component sent by the service consumer; Acquire the running version of the service contract component maintained in the contract management platform, the first compatibility information of the referenced version, and the second verification information and the second compatibility information of the running version; Comparing the reference version with the running version to obtain a first detection result of whether the reference version and the running version are consistent; Determining, according to the referenced version and the second compatibility information, a second detection result of whether the running version is compatible with the referenced version; and / or A third detection result of determining whether the contents of the service contract component of the running version are consistent with the contract component of the referenced version according to the first verification information and the second verification information; It is determined whether a service contract change occurs with the service provider according to the first detection result and at least one of the second detection result and the third detection result.
2. The service contract change detection method according to claim 1, characterized in that: The third detection result of determining whether the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version according to the first verification information and the second verification information includes: comparing the first verification information and the second verification information; In the case where the first verification information and the second verification information are consistent, determining that the third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version; When the first verification information and the second verification information are inconsistent, it is determined that the third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the referenced version.
3. The service contract change detection method according to claim 1, characterized in that: If all of the following conditions are met, it is determined that the service provider has not changed the service contract: The first detection result is that the referenced version and the running version are inconsistent; The second detection result is that the running version is compatible with the referenced version; The third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version.
4. The service contract change detection method according to claim 1, characterized in that: If all of the following conditions are met, it is determined that the service provider has not changed the service contract: The first detection result is that the referenced version is consistent with the running version; The third detection result is that the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version.
5. The service contract change detection method according to claim 1, characterized in that: If all of the following conditions are met, it is determined that the service provider has a service contract change: The first detection result is that the referenced version and the running version are inconsistent; The second detection result is that the running version is incompatible with the referenced version.
6. The service contract change detection method according to claim 1, characterized in that: If all of the following conditions are met, it is determined that the service provider has a service contract change: The first detection result is that the referenced version and the running version are inconsistent; The second detection result is that the running version is compatible with the referenced version; The third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the referenced version.
7. The service contract change detection method according to claim 1, characterized in that: If all of the following conditions are met, it is determined that the service provider has a service contract change: The first detection result is that the referenced version is consistent with the running version; The third detection result is that the content of the service contract component of the running version is inconsistent with the content of the contract component of the referenced version.
8. The service contract change detection method according to any one of claims 1 to 7, characterized in that: The method further comprises: In the case where it is determined that the service provider has a service contract change, an alarm is triggered to prompt the user terminal to determine the impact scope of the service provider's service contract change.
9. The service contract change detection method according to any one of claims 1 to 7, characterized in that: The service contract component is referenced by the service consumer from the central warehouse. The service contract component is constructed by the service provider based on the entity class of the service contract request and return parameters, and is published to the central warehouse.
10. A service contract change detection device, characterized in that: The device comprises: An information receiving module, used for receiving a reference version and first verification information of the service contract component sent by any service consumer after the service contract component of any service provider is referenced by the service consumer; An information acquisition module, used to acquire the running version of the service contract component maintained in the contract management platform, the first compatibility information of the referenced version, and the second verification information and second compatibility information of the running version; A version detection module, used for comparing the reference version with the running version to obtain a first detection result of whether the reference version and the running version are consistent; a compatibility detection module, configured to determine, based on the first compatibility information and the second compatibility information, whether the running version is compatible with the second detection result of the referenced version; and / or A verification information detection module, used to determine a third detection result of whether the content of the service contract component of the running version is consistent with the content of the contract component of the referenced version according to the first verification information and the second verification information; A contract change detection module is used to determine whether a service contract change occurs to the service provider based on the first detection result and at least one of the second detection result and the third detection result.
11. A processor, characterized in that: The method is configured to execute the service contract change detection method according to any one of claims 1 to 9.
12. A machine-readable storage medium having instructions stored thereon, characterized in that: When the instruction is executed by a processor, the processor is configured to execute the service contract change detection method according to any one of claims 1 to 9.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the service contract change detection method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Cache updating method, device, system, electronic equipment and medium
CN110941568A
Configuration file processing method, device, equipment, storage medium and system
CN112416456A
Data change detection method and device, equipment, storage medium and product
CN117555772A
Data processing method based on intelligent contract, device, and storage medium
US20210149663A1