API gateway data synchronization method and device based on strategy mode and task chain, and storage medium
By adopting policy patterns and task chains in API gateway data synchronization, dynamically matching synchronization policy classes, the problem of poor flexibility in gateway data synchronization in the existing technology is solved, and flexible adaptation to different gateway data is achieved.
Patent Information
- Application Number
- CN202510459055.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2045-04-14
AI Technical Summary
The existing API gateway data synchronization technology adopts hard-coded methods, which is difficult to adapt to the diversified needs of different gateway data, resulting in poor flexibility in gateway data synchronization.
The API gateway data synchronization method based on policy patterns and task chains is adopted. By obtaining the gateway type, version number and port address, dynamically match the pull synchronization policy class, and calling the synchronization interface to pull data from the gateway, realizing the execution of data synchronization tasks.
It improves the flexibility of gateway data synchronization, and can dynamically select appropriate synchronization policy classes based on the gateway type and version number, adapt to gateway changes, and enhances the adaptability of multi-gateway platforms.
Smart Images

Figure CN120017662A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to an API gateway data synchronization method, device and storage medium based on a policy mode and a task chain. Background Art
[0002] In the microservice architecture, the API (Application Programming Interface) gateway serves as a unified request entry point and is responsible for processing various business-independent logics, such as routing, load balancing, protocol conversion, and security protection, while each microservice focuses on the implementation of its own business logic. In order to ensure the stable operation and data consistency of the entire microservice architecture, data synchronization of multiple API gateways is required to achieve unified management and update of information such as service lists, API lists, and related policies.
[0003] At present, API gateway data synchronization technology usually adopts a hard-coded method. For example, if a multi-gateway platform manages multiple API gateways, when the multi-gateway platform needs to synchronize the data of the API gateways it manages, it will write code in advance in the data synchronization module and define the relevant data processing logic. When the multi-gateway platform needs to synchronize gateway data, it will first receive the data, and then perform data synchronization processing according to the pre-defined data processing logic. However, the above hard-coded synchronization method is difficult to adapt to the diverse needs of different gateway data, because different types of gateways may have different data formats and synchronization interfaces. The data processing logic defined in advance in the data synchronization module cannot meet the diverse needs of different gateways, and the flexibility of gateway data synchronization is poor.
[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of this application is to provide an API gateway data synchronization method, device and storage medium based on policy mode and task chain, aiming to solve the technical problem of poor flexibility of gateway data synchronization.
[0006] To achieve the above objectives, the present application proposes an API gateway data synchronization method based on a strategy pattern and a task chain, the method comprising: When the scheduled synchronization task chain of the gateway triggers the data pull synchronization task, the type, version number and port address of the gateway are obtained; Based on the type and version number of the gateway, matching the configuration parameters in the data synchronization policy class, determining the pull synchronization policy class corresponding to the gateway; Based on the pull synchronization policy class and the type, version number and port address of the gateway, a synchronization interface is called to pull data from the gateway to execute the data pull synchronization task.
[0007] In one embodiment, when the scheduled synchronization task chain of the gateway triggers the data pull synchronization task on a regular basis, before the step of obtaining the type, version number and port address of the gateway, it also includes: In response to a new gateway instruction input by a user, obtaining the type, version number and port address of the new gateway input by the user; Based on the type, version number and port address of the newly added gateway input by the user, a scheduled synchronization task chain of the newly added gateway is created according to preset rules, and the scheduled synchronization task chain of the newly added gateway is controlled to trigger the data pull synchronization task.
[0008] In one embodiment, the step of calling a synchronization interface to pull data from the gateway based on the pull synchronization policy class and the type, version number and port address of the gateway includes: Read the pull implementation class list in the gateway adapter SDK through the pull synchronization strategy class; The pull synchronization strategy class is matched in the pull implementation class list based on the type and version number of the gateway to determine the target pull implementation class; Based on the target pull implementation class and the port address of the gateway, a synchronous interface is called to pull data from the gateway.
[0009] In one embodiment, when the scheduled synchronization task chain of the gateway triggers the data pull synchronization task on a regular basis, before the step of obtaining the type, version number and port address of the gateway, it also includes: Define a service provider interface, which includes a data pull interface and a data push interface, wherein the data pull interface is used to declare the synchronous data pull method that different gateway service providers need to implement, and the data push interface is used to declare the synchronous data push method that different gateway service providers need to implement; The gateway adapter SDK sent by the receiving gateway service provider based on the service provider interface includes an implementation class, wherein the implementation class includes a pull implementation class and a push implementation class, the pull implementation class is used to implement the synchronous data pulling method, and the push implementation class is used to implement the synchronous data pushing method.
[0010] In one embodiment, the step of calling a synchronous interface to pull data from the gateway based on the target pull implementation class and the port address of the gateway includes: Determining a synchronization interface corresponding to the gateway based on the port address of the gateway; Based on the synchronous data pulling method corresponding to the target pull implementation class, data is pulled from the gateway through the synchronous interface.
[0011] In one embodiment, the method further comprises: Receive new configuration data of the gateway input by the user, and generate a real-time push synchronization task; Based on the type and version number of the gateway, matching the configuration parameters in the data synchronization policy class, determining the push synchronization policy class corresponding to the real-time push synchronization task; Read the push implementation class list in the gateway adapter SDK through the push synchronization strategy class; The push synchronization strategy class is matched in the push implementation class list based on the type and version number of the gateway to determine the target push implementation class; Based on the synchronous data push method corresponding to the target push implementation class, the synchronization interface is called to push the newly added configuration data to the gateway to execute the real-time push synchronization task.
[0012] In one embodiment, the scheduled synchronization task chain includes at least one of the data pull synchronization tasks, the scheduled synchronization task chain is stored in a task engine, and the method further includes: Receive a control signal from a task engine console, where the control signal is used to trigger the execution of any one or more target data pulling synchronization tasks in the scheduled synchronization task chain of the gateway; Based on the control signal, the scheduled synchronization task chain of the control gateway is controlled to trigger the target data pulling synchronization task.
[0013] In one embodiment, after the step of controlling the scheduled synchronization task chain of the gateway to trigger the target data pulling synchronization task based on the control signal, the method further includes: After the target data pulling synchronization task is completed, a downstream data pulling synchronization task is executed, and the downstream data pulling synchronization task is located after the target data pulling synchronization task.
[0014] In addition, to achieve the above-mentioned objectives, the present application also proposes an API gateway data synchronization device based on a policy pattern and a task chain, the device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the API gateway data synchronization method based on a policy pattern and a task chain as described above.
[0015] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the API gateway data synchronization method based on the policy pattern and task chain as described above are implemented.
[0016] The present application provides an API gateway data synchronization method based on a policy pattern and a task chain. When the scheduled synchronization task chain of the gateway triggers a data pull synchronization task, the type, version number and port address of the gateway are obtained. Based on the type and version number of the gateway, the configuration parameters in the data synchronization policy class are matched to determine the pull synchronization policy class corresponding to the gateway. Then, based on the pull synchronization policy class and the type, version number and port address of the gateway, the synchronization interface is called to pull data from the gateway to execute the data pull synchronization task. When the multi-gateway platform needs to execute data pull synchronization, the above method can dynamically match the pull synchronization policy class in the data synchronization policy class according to the type and version number of the gateway. When the gateway type or version in the multi-gateway platform changes, the multi-gateway platform can select different pull synchronization policy classes to adapt to the changes in the gateway, thereby improving the flexibility of gateway data synchronization. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] Figure 1 A flowchart diagram of an API gateway data synchronization method embodiment 1 based on a strategy mode and a task chain is provided for this application; Figure 2 A flow chart of the second embodiment of the API gateway data synchronization method based on the strategy mode and task chain of this application; Figure 3 A flowchart diagram of the third embodiment of the API gateway data synchronization method based on the strategy mode and task chain of this application; Figure 4 A flowchart diagram of the fourth embodiment of the API gateway data synchronization method based on the strategy mode and task chain of this application is provided; Figure 5 A flowchart diagram of the fifth embodiment of the API gateway data synchronization method based on the strategy mode and task chain of this application is provided; Figure 6 A schematic diagram of a method flow involved in an API gateway data synchronization method based on a strategy pattern and a task chain in an embodiment of the present application; Figure 7 This is a schematic diagram of the device structure of the hardware operating environment involved in the API gateway data synchronization method based on the policy mode and task chain in the embodiment of the present application.
[0020] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0021] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0022] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0023] In the microservice architecture, the API gateway serves as a unified request entry point and is responsible for processing various business-independent logics, such as routing, load balancing, protocol conversion, and security protection, while each microservice focuses on the implementation of its own business logic. In order to ensure the stable operation and data consistency of the entire microservice architecture, multiple API gateways need to be synchronized to achieve unified management and update of information such as service lists, API lists, and related policies.
[0024] At present, API gateway data synchronization technology usually adopts a hard-coded method. For example, if a multi-gateway platform manages multiple API gateways, when the multi-gateway platform needs to synchronize the data of the API gateways it manages, it will write code in advance in the data synchronization module and define the relevant data processing logic. When the multi-gateway platform needs to synchronize gateway data, it will first receive the data, and then perform data synchronization processing according to the pre-defined data processing logic. However, the above hard-coded synchronization method is difficult to adapt to the diverse needs of different gateway data, because different types of gateways may have different data formats and synchronization interfaces. The data processing logic defined in advance in the data synchronization module cannot meet the diverse needs of different gateways, and the flexibility of gateway data synchronization is poor.
[0025] In view of the above problems, the present application proposes an API gateway data synchronization method based on a policy pattern and a task chain. When the scheduled synchronization task chain of the gateway triggers the data pull synchronization task on a regular basis, the type, version number and port address of the gateway are obtained. Based on the type and version number of the gateway, the configuration parameters in the data synchronization policy class are matched to determine the pull synchronization policy class corresponding to the gateway. Then, based on the pull synchronization policy class and the type, version number and port address of the gateway, the synchronization interface is called to pull data from the gateway to execute the data pull synchronization task. When the multi-gateway platform needs to execute data pull synchronization, the above method can dynamically match the pull synchronization policy class in the data synchronization policy class according to the type and version number of the gateway. When the gateway type or version in the multi-gateway platform changes, the multi-gateway platform can select different pull synchronization policy classes to adapt to the changes in the gateway, thereby improving the flexibility of gateway data synchronization.
[0026] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, or an electronic device capable of implementing the above functions, etc. The following takes the multi-gateway platform as an example to illustrate this embodiment and the following embodiments.
[0027] Based on this, the first embodiment proposed in this application provides an API gateway data synchronization method based on a strategy mode and a task chain, referring to Figure 1 In this embodiment, the API gateway data synchronization method based on the strategy mode and task chain includes steps S10 to S30: Step S10, when the scheduled synchronization task chain of the gateway triggers the data pulling synchronization task on a scheduled basis, the type, version number and port address of the gateway are obtained.
[0028] It should be noted that the multi-gateway platform can manage and synchronize data from multiple API gateways of different manufacturers and versions. As a key component in the system architecture, the API gateway acts as an intermediary between the client and the backend service, responsible for processing and routing client requests, and provides a series of functions to ensure that the client can call the backend service safely and reliably. The multi-gateway platform is a tool for unified management and configuration of these gateways. When the multi-gateway platform adds a new managed gateway, the multi-gateway platform can automatically synchronize the configuration data of the newly added gateway. The scheduled synchronization task chain refers to an ordered collection of data pull synchronization tasks, which defines the pull synchronization tasks for different types of data in the gateway. The scheduled synchronization task chain automatically triggers the data pull synchronization task according to the preset time interval or specific time point.
[0029] Each gateway managed in the multi-gateway platform corresponds to a scheduled synchronization task chain. When the scheduled synchronization task chain of any gateway triggers a data pull synchronization task, the multi-gateway platform will first obtain the type, version number and port address of the gateway. Among them, the type of gateway is a classification identification of the gateway, which is divided according to the core technical architecture, deployment method, supported functional features, and compatible protocol standards adopted by the gateway. For example, the gateway based on the high-performance open source reverse proxy server NGINX, the "Apache APISIX" gateway developed based on the high-performance open source server Apache, and the "Spring Cloud Gateway" gateway designed for microservice architecture. The version number is an identification of different versions of the same type of gateway, which is used to distinguish the status and differences of the gateway in terms of functions, performance, security, etc. at different time points, such as 1.20.0, 1.22.1, etc. of the "ApacheAPISIX" gateway.
[0030] Step S20, based on the type and version number of the gateway, matching with the configuration parameters in the data synchronization policy class, determining the pull synchronization policy class corresponding to the gateway.
[0031] The data synchronization policy class is a tool class in the multi-gateway platform, which is used to load the implementation method corresponding to the data synchronization task when implementing the data synchronization task, such as the ServiceLoader class in JAVA, where the ServiceLoader class belongs to the Java service provider mechanism, allowing applications to dynamically discover and load service implementations. In this embodiment, the data synchronization policy class can select a suitable implementation method to perform data pull synchronization tasks according to the type and version number of the gateway. There are multiple data synchronization policy classes stored in the multi-gateway platform, and these data synchronization policy classes correspond one-to-one to gateways of different types and version numbers. The multi-gateway platform matches the configuration parameters of the data synchronization policy class according to the type and version number of the gateway to determine the pull synchronization policy class corresponding to the gateway.
[0032] Step S30, based on the pull synchronization policy class and the type, version number and port address of the gateway, calling the synchronization interface to pull data from the gateway to execute the data pull synchronization task.
[0033] Optionally, step S30 includes steps S31 to S33: Step S31, reading the pull implementation class list in the gateway adapter SDK through the pull synchronization strategy class.
[0034] It should be noted that the gateway adapter SDK (Software Development Kit) is designed by different gateway service providers to realize data interaction between the gateways they provide and multiple gateway platforms.
[0035] Optionally, the multi-gateway platform includes a preset first gateway adapter SDK and a second gateway adapter SDK written by the gateway service provider through the SPI (Service Provider Interface) protocol.
[0036] Specifically, the multi-gateway platform includes a set of built-in standard first gateway adapter SDKs. These gateway adapter SDKs are pre-designed and implemented for common gateway types and versions, and can be used directly without additional development. At the same time, the multi-gateway platform also provides the SPI protocol, allowing third-party gateway service providers to write their own gateway adapter SDKs to integrate with the multi-gateway platform. Among them, SPI defines a set of interfaces or abstract classes for implementing specific services, allowing multiple different implementation classes to provide the same functionality.
[0037] For example, an SPI named "A.AbcDef" is defined in the multi-gateway platform. "A.AbcDef" defines the functions that the gateway service provider needs to implement, such as realizing data pull synchronization. Then the gateway service provider can develop a gateway adapter SDK according to the SPI protocol, and write two pull implementation classes "A.AbcDeflmpl1" and "A.AbcDeflmpl2" in the gateway adapter SDK. Two different data pull synchronization methods are defined in these two pull implementation classes to implement data pull synchronization tasks for gateways of different types and version numbers. When the gateway service provider registers the gateway adapter SDK to the multi-gateway platform, all the pull implementation classes in the gateway adapter SDK will be included in the configuration file of the multi-gateway platform, namely the above-mentioned "A.AbcDeflmpl1" and "A.AbcDeflmpl2". The multi-gateway platform can read all the pull implementation classes, that is, the pull implementation class list, from the configuration file through the pull synchronization policy class.
[0038] Step S32: The pull synchronization strategy class is matched in the pull implementation class list based on the type and version number of the gateway to determine the target pull implementation class.
[0039] It should be noted that different gateway types or versions may have different data formats, encryption methods or communication protocols. Therefore, different gateway service providers will also define different data communication methods based on the gateway type and version. The implementation class list includes all pull implementation classes in the gateway adapter SDK, and each pull implementation class corresponds to a specific gateway type and version. The pull synchronization strategy class will find the pull implementation class that matches the gateway that currently triggers the data pull synchronization task among the pull implementation classes in all gateway adapter SDKs based on the gateway type and version number.
[0040] Step S33: Based on the target pull implementation class and the port address of the gateway, a synchronous interface is called to pull data from the gateway.
[0041] The port address of the gateway specifies the network port of the gateway from which the multi-gateway platform should obtain synchronization data. During the data synchronization process, the multi-gateway platform uses this port address to call the synchronization interface to establish a connection with the gateway. The target pull implementation class contains all the logic required for synchronization data, including how to build requests, how to handle responses, and how to parse returned data. The synchronization interface builds requests through the algorithm defined in the target pull implementation class and pulls data from the gateway through the gateway's port address. After receiving the request, the gateway will process it according to the content of the request and return the corresponding data. The synchronization interface of the multi-gateway platform will receive the returned data and use the parsing logic defined in the target pull implementation class to parse the data. The parsed data is stored in the specified location of the multi-gateway platform to complete the data synchronization task.
[0042] In this embodiment, the target pull implementation class can separate the implementation of the algorithm from the code that uses the algorithm. The specific implementation code of the algorithm is encapsulated in the target pull implementation class, and the data synchronization module in the multi-gateway platform only needs to write the usage code of the target pull implementation class. In this way, when the type and version of the gateway managed in the multi-platform changes, or the synchronization data type changes, it is only necessary to add a new data synchronization policy class to the configuration file of the multi-gateway platform, or change and replace the target pull implementation class, without changing the code of the data synchronization module inside the multi-gateway platform, thereby improving the flexibility of gateway data synchronization.
[0043] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can refer to the above introduction, and will not be repeated later. Figure 2 Before step S10, the API gateway data synchronization method based on the strategy mode and task chain also includes steps S40 to S50: Step S40, in response to the new gateway instruction input by the user, obtaining the type, version number and port address of the new gateway input by the user.
[0044] Step S50, based on the type, version number and port address of the newly added gateway input by the user, a scheduled synchronization task chain of the newly added gateway is created according to preset rules, and the scheduled synchronization task chain of the newly added gateway is controlled to trigger a data pull synchronization task.
[0045] The multi-gateway platform provides a user interface. When a user needs to add a managed gateway to the multi-gateway platform, he can enter the new gateway command on the user interface of the multi-gateway platform and enter the attribute parameters such as the Internet protocol address, type, version number, port address and communication protocol of the new gateway. If the multi-gateway platform detects the new gateway command entered by the user through the preset detection mechanism, it will generate the corresponding scheduled synchronization task chain according to the type, version number and port address of the new gateway entered by the user.
[0046] Optionally, the data pull synchronization task type and order of the scheduled synchronization task chain are preset in advance. For example, four data pull synchronization tasks are preset and executed in the preset order: "system data pull synchronization task -> application data pull synchronization task -> API and policy data pull synchronization task -> service and policy data pull synchronization task". When the scheduled synchronization task chain triggers the data pull synchronization task, data pull will be executed in sequence in the above preset order.
[0047] It should be noted that the trigger frequency of the scheduled synchronization task chain can be set according to actual business needs, such as triggering a data pull synchronization task once a day or a week. When a new gateway is added to the multi-gateway platform and a scheduled synchronization task chain corresponding to the new gateway is created, a data pull synchronization task is immediately triggered to pull data from the new gateway and synchronize it to the multi-gateway platform.
[0048] Optionally, when a user edits the attribute parameters of a managed gateway, such as a port address, through the user interface of the multi-gateway platform, the current scheduled synchronization task chain of the gateway is deleted, a new scheduled synchronization task chain is recreated based on the edited gateway attribute parameters, and a data pull synchronization task is immediately triggered.
[0049] If a user deletes a managed gateway through the user interface of the multi-gateway platform, the scheduled synchronization task chain of the gateway will be deleted, but the synchronized data in the multi-gateway platform will be retained.
[0050] Based on the above embodiments of the present application, in the third embodiment of the present application, the same or similar contents as those in the above embodiments can be referred to the above introduction, and will not be described in detail later. Figure 3Before step S10, the API gateway data synchronization method based on the strategy mode and task chain further includes steps S60 to S70: Step S60, define the service provider interface, which includes a data pull interface and a data push interface, wherein the data pull interface is used to declare the synchronous data pull method that different gateway service providers need to implement, and the data push interface is used to declare the synchronous data push method that different gateway service providers need to implement.
[0051] SPI provides a standardized access point for different gateway service providers, ensuring that they can interact with the multi-gateway platform in a unified way. The data pull interface declares a series of synchronous data pull methods, which can be implemented by each gateway service provider according to their own gateway characteristics, and defines the specific logic of how to pull data from the gateway, including building requests, sending requests, processing responses, and parsing data. The data push interface declares synchronous data push methods.
[0052] Step S70, receiving the gateway adapter SDK sent by the gateway service provider based on the service provider interface, the gateway adapter SDK includes an implementation class, wherein the implementation class includes a pull implementation class and a push implementation class, the pull implementation class is used to implement the synchronous data pulling method, and the push implementation class is used to implement the synchronous data pushing method.
[0053] Through SPI, the multi-gateway platform can receive gateway adapter SDKs from various gateway service providers. These SDKs contain implementation classes written by service providers based on different types and versions of gateways, namely pull implementation classes and push implementation classes. The implementation class encapsulates the code for implementing data push and data pull. By loading and using these SDKs, the multi-gateway platform can flexibly support multiple gateway types without hard-coding the specific data synchronization logic for each gateway.
[0054] Optionally, in step S33, when the multi-gateway platform calls the synchronous interface to pull data from the gateway based on the target pull implementation class and the port address of the gateway, it first determines the synchronous interface corresponding to the gateway based on the port address of the gateway, and then pulls data from the gateway through the synchronous interface based on the synchronous data pulling method corresponding to the target pull implementation class.
[0055] When the gateway can use more than one port address to implement the data pull synchronization task, the gateway service provider can define the port address corresponding to the implementation class in the data pull implementation class. When the multi-gateway platform obtains the target pull implementation class, it calls the synchronization interface to connect to the port address specified in the target pull implementation class to perform the data pull synchronization task.
[0056] In this embodiment, by defining a standardized SPI, gateway service providers can implement data pull and push methods according to their own gateway characteristics, so that the multi-gateway platform can dynamically support data synchronization tasks of different gateways by loading SDK, thereby improving the flexibility of gateway data synchronization.
[0057] Based on the above embodiments of the present application, in the fourth embodiment of the present application, the same or similar contents as those in the above embodiments can be referred to the above introduction, and will not be described in detail later. Figure 4 The API gateway data synchronization method based on the strategy mode and the task chain also includes steps S80 to S120: Step S80, receiving the newly added configuration data of the gateway input by the user, and generating a real-time push synchronization task.
[0058] Users can input new configuration data of the gateway through the user interface of the multi-gateway platform to update the configuration data of all managed gateways. The multi-gateway platform generates a real-time push task based on the new configuration data input by the user, and pushes the above new configuration data to all existing managed gateways.
[0059] Step S90, based on the type and version number of the gateway, matching with the configuration parameters in the data synchronization policy class, determining the push synchronization policy class corresponding to the real-time push synchronization task.
[0060] In this embodiment, the data synchronization policy class can select an appropriate implementation method to perform real-time push synchronization tasks according to the type and version number of the gateway. A variety of data synchronization policy classes are stored in the multi-gateway platform, and these data synchronization policy classes correspond one-to-one to gateways of different types and version numbers. The multi-gateway platform matches the configuration parameters of the data synchronization policy class according to the type and version number of the gateway to determine the push synchronization policy class corresponding to the gateway.
[0061] Step S100: reading a push implementation class list in the gateway adapter SDK through the push synchronization strategy class.
[0062] Step S110: The push synchronization policy class is matched in the push implementation class list based on the type and version number of the gateway to determine a target push implementation class.
[0063] The multi-gateway platform can read all push implementation classes, i.e., the push implementation class list, from the configuration file by pulling the synchronization strategy class. The implementation class list includes push implementation classes in all gateway adapter SDKs, and each push implementation class corresponds to a specific gateway type and version. The push synchronization strategy class will find the push implementation class that matches the gateway of the current real-time push synchronization task among the push implementation classes in all gateway adapter SDKs based on the gateway type and version number.
[0064] Step S120: Based on the synchronization data push method corresponding to the target push implementation class, the synchronization interface is called to push the newly added configuration data to the gateway to execute the real-time push synchronization task.
[0065] The multi-gateway platform uses the synchronous data push method defined in the target push implementation class. This method contains all the logic required to push the newly added configuration data to the gateway, including building a request, setting authentication information, sending data, etc. The multi-gateway platform calls the synchronous data push method defined in the push implementation class, obtains the port address of the gateway, and connects to the port address through the synchronization interface to push the newly added configuration data to the gateway. This process completes the real-time push synchronization task and ensures that the gateway can receive the latest configuration data and update accordingly.
[0066] Based on the above embodiments of the present application, in the fifth embodiment of the present application, the same or similar contents as those in the above embodiments can be referred to the above introduction, and will not be described in detail later. Figure 5 , the scheduled synchronization task chain includes at least one of the data pull synchronization tasks, the scheduled synchronization task chain is stored in the task engine, and the API gateway data synchronization method based on the strategy mode and task chain also includes steps S130~S140: Step S130, receiving a control signal from a task engine console, wherein the control signal is used to trigger the execution of any one or more target data pulling synchronization tasks in the scheduled synchronization task chain of the gateway.
[0067] Step S140: Based on the control signal, the scheduled synchronization task chain of the control gateway is controlled to trigger the target data pulling synchronization task.
[0068] It should be noted that the task engine console is a user interface or management tool that allows users to monitor, manage and trigger data pull synchronization tasks in the scheduled synchronization task chain. The task engine console can provide an intuitive operation interface for users to interact with the task engine. The control signal is a signal input by the user through the task engine console to indicate which data pull synchronization task needs to be executed, including specific information about the target data pull synchronization task, such as a task identifier or other unique identifier.
[0069] Optionally, the scheduled synchronization task chain is saved in the xxl-job task engine, where xxl-job is a distributed task scheduling framework that provides powerful distributed task scheduling capabilities, can realize the distribution and execution of tasks in the cluster, and provide visual management, monitoring and task execution logs.
[0070] Optionally, after the target data pull synchronization task is completed, a downstream data pull synchronization task is executed, and the downstream data pull synchronization task is located after the target data pull synchronization task.
[0071] The data pull synchronization tasks in the scheduled synchronization task chain are arranged in a specific order. When the target data pull synchronization task is completed, if there are downstream data pull synchronization tasks after the scheduled synchronization task chain, these downstream data pull synchronization tasks will be automatically executed in sequence according to the order defined in the scheduled synchronization task chain.
[0072] Optionally, when an exception occurs during the execution of a data pull synchronization task in the scheduled synchronization task chain, the user can manually trigger the restart of one or more data pull synchronization tasks in the scheduled synchronization task chain in the task engine console to ensure the continuity and stability of data synchronization.
[0073] In this embodiment, through the task engine console, users can intuitively monitor and manage each task in the scheduled synchronization task chain, and manually trigger the execution of any target data pull synchronization task as needed. This manual trigger mechanism enables the multi-gateway platform to respond quickly and start or restart related tasks in time to ensure the continuity and stability of data synchronization if an abnormal situation is encountered or a specific task needs to be prioritized during the data synchronization process.
[0074] For example, in order to help understand the implementation process of the API gateway data synchronization method based on the strategy mode and task chain obtained by combining this embodiment with the above embodiments, please refer to Figure 6 , Figure 6 A brief flowchart of the API gateway data synchronization method based on the strategy mode and task chain is provided. Specifically: The multi-gateway platform manages multiple gateways, including the gateway type, gateway version, communication protocol, domain name address and authentication parameters of each gateway. When the multi-gateway platform adds a new gateway or edits an existing managed gateway, it can generate a scheduled synchronization task chain, which includes system data pull synchronization tasks, application data pull synchronization tasks, application programming interface and policy data pull synchronization tasks, and service and policy data pull synchronization tasks. These pull synchronization tasks are managed by the task engine. The task engine supports scheduled calls to scheduled synchronization task chains to execute data pull synchronization tasks, and also supports manual selection of target data pull synchronization tasks to execute. At the same time, when the service management module and the application programming interface management module modify and edit the service policy configuration data and the application programming interface policy configuration data, they can generate real-time push synchronization tasks to execute the push and distribution of the gateway's service and related policy update configuration data. For example, if Figure 6 As shown, the multi-gateway platform is configured with two data synchronization policy classes: "A Gateway V1.3.2 Data Synchronization Policy Class" and "B Gateway V1.2.2 Data Synchronization Policy Class"; it is also configured with three gateway adapter SDKs: "Software Development Kit 1", "Software Development Kit 2" and "Software Development Kit 3". The data synchronization policy class can obtain the corresponding target data synchronization policy class according to the type and version number of the gateway. The target data synchronization policy class then searches for the implementation class in the corresponding gateway adapter according to the type and version number of the gateway, and performs the synchronization task according to the data synchronization method defined in the implementation class. Among them, the service provider interface includes a data pull interface and a data push interface. Gateway service providers can write their own gateway adapter SDK through the SPI protocol and integrate it with the multi-gateway platform to achieve gateway management.
[0075] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the API gateway data synchronization method based on the strategy pattern and task chain of the present application. More forms of simple transformations based on this technical concept are all within the scope of protection of the present application.
[0076] The present application provides an API gateway data synchronization device based on a policy pattern and a task chain. The API gateway data synchronization device based on a policy pattern and a task chain includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the API gateway data synchronization method based on the policy pattern and the task chain in the above-mentioned embodiment one.
[0077] Reference below Figure 7, which shows a schematic diagram of the structure of an API gateway data synchronization device based on a policy mode and a task chain suitable for implementing an embodiment of the present application. The API gateway data synchronization device based on a policy mode and a task chain in the embodiment of the present application may include but is not limited to mobile terminals such as a laptop computer PAD (tablet computer, Portable Application Description) and fixed terminals such as a desktop computer. Figure 7 The API gateway data synchronization device based on the policy pattern and task chain shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0078] like Figure 7 As shown, the API gateway data synchronization device based on the strategy mode and the task chain may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM, Read Only Memory) 1002 or the program loaded from the storage device 1003 to the random access memory (RAM, Random Access Memory) 1004. In the random access memory 1004, various programs and data required for the operation of the API gateway data synchronization device based on the strategy mode and the task chain are also stored. The processing device 1001, the read-only memory 1002 and the random access memory 1004 are connected to each other through a bus 1005. The input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can allow the API gateway data synchronization device based on the policy mode and the task chain to communicate wirelessly or wired with other devices to exchange data. Although the figure shows an API gateway data synchronization device based on the policy mode and the task chain with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or provided alternatively.
[0079] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a read-only memory 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0080] The API gateway data synchronization device based on policy mode and task chain provided by the present application adopts the API gateway data synchronization method based on policy mode and task chain in the above embodiment, which can solve the technical problem of poor flexibility of gateway data synchronization. Compared with the prior art, the beneficial effects of the API gateway data synchronization device based on policy mode and task chain provided by the present application are the same as the beneficial effects of the API gateway data synchronization method based on policy mode and task chain provided by the above embodiment, and the other technical features in the API gateway data synchronization device based on policy mode and task chain are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0081] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0082] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0083] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, the computer-readable program instructions being used to execute the API gateway data synchronization method based on policy patterns and task chains in the above-mentioned embodiments.
[0084] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory (EPROM, Erasable Programmable ReadOnly Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM, CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, radio frequencies (RF, Radio Frequency), etc., or any suitable combination of the above.
[0085] The above-mentioned computer-readable storage medium may be included in the API gateway data synchronization device based on the policy mode and the task chain; or it may exist independently without being assembled into the API gateway data synchronization device based on the policy mode and the task chain.
[0086] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the API gateway data synchronization device based on the policy mode and the task chain, the API gateway data synchronization device based on the policy mode and the task chain can be written in one or more programming languages or a combination thereof to perform the computer program code for the operation of the present application. The above-mentioned programming language includes an object-oriented programming language such as Java, Smalltalk, C++, and also includes a conventional procedural programming language such as "C" language or a similar programming language. The program code can be executed entirely on the user's computer, partially on the user's computer, or as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0087] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0088] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0089] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned API gateway data synchronization method based on policy patterns and task chains, and can solve the technical problem of poor flexibility of gateway data synchronization. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the API gateway data synchronization method based on policy patterns and task chains provided by the above-mentioned embodiments, and will not be repeated here.
[0090] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. An API gateway data synchronization method based on strategy mode and task chain, characterized in that: The method comprises: When the scheduled synchronization task chain of the gateway triggers the data pull synchronization task, the type, version number and port address of the gateway are obtained; Based on the type and version number of the gateway, matching the configuration parameters in the data synchronization policy class, determining the pull synchronization policy class corresponding to the gateway; Based on the pull synchronization policy class and the type, version number and port address of the gateway, a synchronization interface is called to pull data from the gateway to execute the data pull synchronization task.
2. The API gateway data synchronization method based on strategy mode and task chain as claimed in claim 1, characterized in that: When the scheduled synchronization task chain of the gateway triggers the data pulling synchronization task on a regular basis, before the step of obtaining the type, version number and port address of the gateway, the step further includes: In response to a new gateway instruction input by a user, obtaining the type, version number and port address of the new gateway input by the user; Based on the type, version number and port address of the newly added gateway input by the user, a scheduled synchronization task chain of the newly added gateway is created according to preset rules, and the scheduled synchronization task chain of the newly added gateway is controlled to trigger the data pull synchronization task.
3. The API gateway data synchronization method based on strategy mode and task chain as claimed in claim 1, characterized in that: The step of calling a synchronization interface to pull data from the gateway based on the pull synchronization strategy class and the type, version number and port address of the gateway includes: Read the pull implementation class list in the gateway adapter SDK through the pull synchronization strategy class; The pull synchronization strategy class is matched in the pull implementation class list based on the type and version number of the gateway to determine the target pull implementation class; Based on the target pull implementation class and the port address of the gateway, a synchronous interface is called to pull data from the gateway.
4. The API gateway data synchronization method based on strategy mode and task chain as described in claim 3 is characterized in that: When the scheduled synchronization task chain of the gateway triggers the data pulling synchronization task on a regular basis, before the step of obtaining the type, version number and port address of the gateway, the step further includes: Define a service provider interface, which includes a data pull interface and a data push interface, wherein the data pull interface is used to declare the synchronous data pull method that different gateway service providers need to implement, and the data push interface is used to declare the synchronous data push method that different gateway service providers need to implement; The gateway adapter SDK sent by the receiving gateway service provider based on the service provider interface includes an implementation class, wherein the implementation class includes a pull implementation class and a push implementation class, the pull implementation class is used to implement the synchronous data pulling method, and the push implementation class is used to implement the synchronous data pushing method.
5. The API gateway data synchronization method based on strategy mode and task chain as claimed in claim 4, characterized in that: The step of calling a synchronous interface to pull data from the gateway based on the target pull implementation class and the port address of the gateway includes: Determining a synchronization interface corresponding to the gateway based on the port address of the gateway; Based on the synchronous data pulling method corresponding to the target pull implementation class, data is pulled from the gateway through the synchronous interface.
6. The API gateway data synchronization method based on strategy mode and task chain as claimed in claim 4, characterized in that: The method further comprises: Receive new configuration data of the gateway input by the user, and generate a real-time push synchronization task; Based on the type and version number of the gateway, matching the configuration parameters in the data synchronization policy class, determining the push synchronization policy class corresponding to the real-time push synchronization task; Read the push implementation class list in the gateway adapter SDK through the push synchronization strategy class; The push synchronization strategy class is matched in the push implementation class list based on the type and version number of the gateway to determine the target push implementation class; Based on the synchronous data push method corresponding to the target push implementation class, the synchronization interface is called to push the newly added configuration data to the gateway to execute the real-time push synchronization task.
7. The API gateway data synchronization method based on strategy mode and task chain as claimed in claim 1, characterized in that: The scheduled synchronization task chain includes at least one of the data pull synchronization tasks, and the scheduled synchronization task chain is stored in the task engine. The method further includes: Receive a control signal from a task engine console, where the control signal is used to trigger the execution of any one or more target data pulling synchronization tasks in the scheduled synchronization task chain of the gateway; Based on the control signal, the scheduled synchronization task chain of the control gateway is controlled to trigger the target data pulling synchronization task.
8. The API gateway data synchronization method based on strategy mode and task chain as claimed in claim 7, characterized in that: After the step of controlling the scheduled synchronization task chain of the gateway to trigger the target data pulling synchronization task based on the control signal, the method further includes: After the target data pulling synchronization task is completed, a downstream data pulling synchronization task is executed, and the downstream data pulling synchronization task is located after the target data pulling synchronization task.
9. An API gateway data synchronization device based on strategy mode and task chain, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the API gateway data synchronization method based on a policy pattern and a task chain as described in any one of claims 1 to 8.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the API gateway data synchronization method based on the policy pattern and task chain as described in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Data acquisition method and device, client and computer readable storage medium
CN112685192A
Data transmission method and device, electronic equipment and storage medium
CN116095077A
Data scheduling method and device, equipment and medium
CN117349350A
Installation and maintenance terminal information processing method and device based on deep reinforcement learning
CN118799874A
Communication framework for automated content generation and adaptive delivery
US20230169272A1