Data aggregation method and device based on API gateway
By creating API services in the API gateway and orchestrating workflow information, the flexibility and efficiency problems caused by interface complexity in the microservice architecture are solved, and efficient development and expansion of business systems are achieved.
Patent Information
- Application Number
- CN202210764897.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-29
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2042-06-29
AI Technical Summary
In the microservice architecture, the implementation of business system interfaces is too complex, resulting in poor business flexibility and low delivery efficiency, and frequent rewriting of code is required to meet business needs.
Using the data aggregation method based on the API gateway, by creating API services in the API gateway and orchestrating its workflow information, configuring input parameter format, calling steps, atomic service interface parameter format, return data format and call result feedback method, to Meet business needs.
It improves the flexibility and development efficiency of the business system, simplifies the upgrade and expansion of the system, reduces the interaction costs between service providers and callers, and achieves rapid response and data adaptation compatibility.
Smart Images

Figure CN115242629B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network technology, and in particular to a data aggregation method and device based on an API gateway. Background Art
[0002] As microservice architecture becomes more and more popular in enterprise applications, it decouples functions, uses a business system interface to obtain required data from various services, responds quickly to business, and solves complexity problems.
[0003] However, as business needs become increasingly complex, the number of microservices is increasing to meet business needs, resulting in the business logic implemented by the business system interface being too complex, which is not conducive to the upgrade and iteration of the business system. If the microservice interface provides atomic services, the system caller needs to complete the interface assembly and orchestration work, and the code needs to be rewritten. The docking cost is high and it is not conducive to standard unification, resulting in weak business flexibility and low delivery efficiency. Summary of the invention
[0004] The present invention provides a data aggregation method and device based on API gateway, which are used to solve the defects of weak business flexibility and low delivery efficiency in the prior art, so as to improve business flexibility and improve the development efficiency of business systems.
[0005] The present invention provides a data aggregation method based on an API gateway, comprising:
[0006] Based on business needs, create API services in the API gateway, and the API services are implemented through aggregate interfaces;
[0007] Arrange the workflow information corresponding to the API service so that the output of the aggregation interface meets the business requirements;
[0008] The workflow information includes at least one of the following:
[0009] The format of the input parameters of the aggregation interface;
[0010] The calling step of the aggregation interface;
[0011] The format of the atomic service interface input and output parameters of the aggregate interface;
[0012] The return data formats corresponding to the interfaces in the aggregate interface and the templates for processing the return data of the interfaces;
[0013] The format of the output parameters of the aggregation interface;
[0014] The feedback method of the calling result of the aggregation interface and the format of the feedback information.
[0015] According to a data aggregation method based on an API gateway provided by the present invention, when the workflow information includes the format of the input parameters of the aggregation interface, the orchestration of the workflow information corresponding to the API service includes:
[0016] The input parameter format is configured to include: request header, request body and Query parameters.
[0017] According to a data aggregation method based on an API gateway provided by the present invention, when the workflow information includes the calling step, the orchestration of the workflow information corresponding to the API service includes:
[0018] Configuring multiple steps included in the calling step, wherein each step includes a calling request of one or more interfaces, and the calling requests of one or more interfaces in each step are executed in parallel;
[0019] Configuring a serial execution order between the multiple steps;
[0020] Configure the request address, input parameters, data processing method, and call timeout time corresponding to each step.
[0021] According to a data aggregation method based on an API gateway provided by the present invention, when the workflow information includes the format of the input and output parameters of the atomic service interface, the workflow information corresponding to the API service is arranged, including:
[0022] The format for configuring the input and output parameters of each atomic service interface in the aggregate interface includes: fixed value or reference value.
[0023] According to a data aggregation method based on an API gateway provided by the present invention, when the workflow information includes a return data format corresponding to each interface in the aggregated interface and a template for processing the return data of each interface, the workflow information corresponding to the API service is arranged, including:
[0024] The formats of the returned data of the atomic services respectively provided by the interfaces in the aggregate interface and the template for performing data integration processing on all the returned data are configured.
[0025] According to a data aggregation method based on an API gateway provided by the present invention, when the workflow information includes the format of the output parameters of the aggregation interface, the orchestration of the workflow information corresponding to the API service includes:
[0026] Configure the format of the response header and response body for the output parameter.
[0027] According to a data aggregation method based on an API gateway provided by the present invention, when the workflow information includes a feedback mode of a call result of the aggregation interface and a format of the feedback information, the workflow information corresponding to the API service is arranged, including:
[0028] In the case where the aggregate interface fails to call, the feedback method of the call result of the aggregate interface includes: putting the reason for the call failure into the message field of the context;
[0029] Configure the message format of the feedback information.
[0030] According to a data aggregation method based on an API gateway provided by the present invention, when the workflow information includes a feedback mode of a call result of the aggregation interface and a format of the feedback information, the workflow information corresponding to the API service is arranged, including:
[0031] In the case where the aggregate interface fails to call, the feedback method of the call result of the aggregate interface includes: putting the reason for the call failure into the message field of the context;
[0032] Configure the message format of the feedback information.
[0033] According to a data aggregation method based on an API gateway provided by the present invention, when the workflow information includes a feedback mode of a call result of the aggregation interface and a format of the feedback information, the workflow information corresponding to the API service is arranged, including:
[0034] In the case where the aggregate interface fails to call, the feedback method of the call result of the aggregate interface includes: putting the reason for the call failure into the message field of the context;
[0035] Configure the message format of the feedback information.
[0036] The present invention provides a data aggregation device based on an API gateway, comprising:
[0037] A creation module is used to create an API service in the API gateway based on business needs, and the API service is implemented through an aggregate interface;
[0038] An orchestration module, used to orchestrate the workflow information corresponding to the API service so that the output of the aggregation interface meets the business requirements;
[0039] The workflow information includes at least one of the following:
[0040] The format of the input parameters of the aggregation interface;
[0041] The calling step of the aggregation interface;
[0042] The format of the atomic service interface input and output parameters of the aggregate interface;
[0043] The return data formats corresponding to the interfaces in the aggregate interface and the templates for processing the return data of the interfaces;
[0044] The format of the output parameters of the aggregation interface;
[0045] The feedback method of the calling result of the aggregation interface and the format of the feedback information.
[0046] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the data aggregation method based on the API gateway as described above is implemented.
[0047] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described data aggregation methods based on an API gateway.
[0048] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned data aggregation methods based on an API gateway.
[0049] The data aggregation method and device based on API gateway provided by the present invention create API services in API gateway based on business needs, that is, perform aggregation interface, and arrange the format of input parameters of the aggregation interface, calling steps, the format of input and output parameters of atomic service interface, the return data format corresponding to each interface and the template for data processing of the return data of each interface, the format of output parameters, the feedback method of call results and the format of feedback information, and propose a method for building a framework of business system, which can efficiently adjust the framework of business system based on business needs, make system applications and services easier to develop, upgrade, expand and deploy, and improve the development efficiency of business system products. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0051] Figure 1 This is one of the flow charts of the data aggregation method based on API gateway provided by the present invention;
[0052] Figure 2 This is the second flow chart of the data aggregation method based on API gateway provided by the present invention;
[0053] Figure 3 This is the third flow chart of the data aggregation method based on API gateway provided by the present invention;
[0054] Figure 4 It is a structural schematic diagram of a data aggregation device based on an API gateway provided by the present invention;
[0055] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0057] Combine the following Figure 1-Figure 5 The present invention describes the data aggregation method and device based on API gateway.
[0058] Figure 1 This is one of the flow charts of the data aggregation method based on API gateway provided by the present invention, such as Figure 1 As shown, the data aggregation method based on API gateway includes:
[0059] Step 100, based on business requirements, create an API service in an Application Programming Interface (API) gateway, wherein the API service is implemented through an aggregated interface;
[0060] Optionally, you can create a new API service in the API gateway based on specific business needs, and specify information such as the service name, authentication method, request protocol, request method, request path, input parameter request mode (input parameter transparent transmission and parameter mapping), error code definition, and parameter type.
[0061] Specifically, the service name, authentication method, request protocol, request method, request path, input parameter request mode (input parameter transparent transmission and parameter mapping), error code definition, parameter type and other information corresponding to different business needs can be determined by the user based on experience, or by industry default, or determined based on industry protocols, and the present invention is not limited to this.
[0062] For example, the service name, authentication method, request protocol, request method, request path, input parameter request mode (input parameter transparent transmission and parameter mapping), error code definition, parameter type and other information corresponding to the business needs can be determined based on user experience, industry default, or industry protocol, thus completing the steps of creating an API service in the API gateway.
[0063] Step 110, arranging the workflow information corresponding to the API service so that the output of the aggregation interface meets the business requirements;
[0064] The workflow information includes at least one of the following:
[0065] The format of the input parameters of the aggregation interface;
[0066] The calling step of the aggregation interface;
[0067] The format of the atomic service interface input and output parameters of the aggregate interface;
[0068] The return data formats corresponding to the interfaces in the aggregate interface and the templates for processing the return data of the interfaces;
[0069] The format of the output parameters of the aggregation interface;
[0070] The feedback method of the calling result of the aggregation interface and the format of the feedback information.
[0071] Optionally, Figure 2 This is the second flow chart of the data aggregation method based on API gateway provided by the present invention, such as Figure 2 As shown, completing the API gateway service orchestration is mainly divided into the following steps:
[0072] 1. Create an aggregate interface, that is, create an API service in the API gateway;
[0073] 2. Configure input parameters, that is, configure the format of input parameters of the aggregation interface;
[0074] 3. Configure the calling steps, that is, configure the calling steps of the aggregation interface;
[0075] 4. Configure the input and output parameters of the atomic service interface, that is, configure the format of the input and output parameters of the atomic service interface of the aggregate interface;
[0076] 5. Configure step result processing, that is, configure the return data format corresponding to each interface in the aggregation interface and the template for data processing of the return data of each interface;
[0077] 6. Configure output parameters, that is, configure the format of output parameters of the aggregation interface;
[0078] 7. Configure the call result, that is, configure the feedback method and format of the feedback information of the call result of the aggregation interface.
[0079] Specifically, after arranging the workflow information corresponding to the API service, the present invention can realize corresponding to multiple backend services by arranging the service of the API gateway. The request parameters of each backend service can be parameters passed in through the front end, or customized in the arrangement (write static parameters or obtain from the return data). And the return results of each service can be processed (filtering, deleting, moving, renaming, unpacking and packaging, etc.), and finally integrated into a large result return as the result feedback to the caller of the business.
[0080] The data aggregation method based on API gateway provided by the present invention creates API service in API gateway based on business needs, that is, performs aggregation interface, and arranges the format of input parameters of the aggregation interface, calling steps, the format of input and output parameters of atomic service interface, the return data format corresponding to each interface and the template for data processing of the return data of each interface, the format of output parameters, the feedback method of call result and the format of feedback information, and proposes a method for building a framework of business system, which can efficiently adjust the framework of business system based on business needs, make system applications and services easier to develop, upgrade, expand and deploy, and improve the development efficiency of business system products.
[0081] The data aggregation method based on API gateway provided by the present invention can quickly obtain the required data from various services corresponding to the aggregation interface by using API gateway, quickly respond to the business, and adapt the service data for compatibility, which is beneficial to reducing the interaction cost between the service provider and the caller, and making the entire process of service calling more complete and efficient.
[0082] Optionally, in a case where the workflow information includes the format of the input parameters of the aggregation interface, the orchestration of the workflow information corresponding to the API service includes:
[0083] The input parameter format is configured to include: request header, request body and Query parameters.
[0084] Specifically, the definition of configurable input parameters includes three parts: request header, request body, and Query parameters.
[0085] Optionally, the Query parameter is a common way to carry parameters in a request.
[0086] Optionally, when the workflow information includes the calling step, the orchestrating of the workflow information corresponding to the API service includes:
[0087] Configuring multiple steps included in the calling step, wherein each step includes a calling request of one or more interfaces, and the calling requests of one or more interfaces in each step are executed in parallel;
[0088] Configuring a serial execution order between the multiple steps;
[0089] Configure the request address, input parameters, data processing method, and call timeout time corresponding to each step.
[0090] Specifically, the calling steps of an aggregate interface may include multiple steps, any of which may include one or more requests (i.e., calling one or more interfaces), and forwarding services may be added between each interface and / or step, for example, the result of implementing service A may be used as the input of service B;
[0091] Optionally, the multiple steps are executed in series, so the serial execution order of the multiple steps can be configured;
[0092] Optionally, multiple requests within a step can be executed in parallel.
[0093] Optionally, each time you configure a step, you need to configure the corresponding request address of the step, the parameters passed in, what to do with the returned data, and the call timeout period, etc.
[0094] Optionally, the request address, input parameters, data processing method, and call timeout time corresponding to each step may be the request address, input parameters, data processing method, and call timeout time of one or more requests included in the step.
[0095] It should be noted that the request address corresponding to each step, the parameters passed in, the processing of the returned data, and the call timeout period may be determined by the user based on experience and business needs, or may be industry defaults, or may be determined based on industry protocols, and the present invention does not limit this.
[0096] Optionally, the steps included in the calling steps of an aggregate interface may be determined by the user based on experience and business needs, or may be industry default, or may be determined based on industry protocols, and the present invention does not limit this.
[0097] Optionally, one or more requests included in each step may be determined by the user based on experience and business needs, or may be industry default, or may be determined based on industry agreements, which is not limited in the present invention;
[0098] Optionally, the serial execution order between the multiple steps may be determined by the user based on experience and business needs, or may be industry default, or may be determined based on industry agreements, and the present invention is not limited to this.
[0099] Optionally, the present invention can also implement repeated calls to atomic services through workflow orchestration.
[0100] Optionally, when the workflow information includes the format of the input and output parameters of the atomic service interface, the arranging the workflow information corresponding to the API service includes:
[0101] The format for configuring the input and output parameters of each atomic service interface in the aggregate interface includes: fixed value or reference value.
[0102] Optionally, the input and output parameters of the atomic service interface can support configuration of fixed values or reference values;
[0103] Optionally, the atomic service interface input and output parameters can support configuration scripts;
[0104] Optionally, a fixed value is a parameter that uses a fixed value for parameter transmission;
[0105] Optionally, reference values are passed by referencing other data, and reference rules can be defined: (1) The parameters passed in by the front end can be written as: input.request.body.parameter name, or input.request.header.parameter name; (2) The gateway calls the forwarding process of the API in the orchestration process (forward -> obtain return data -> data processing) a Step, and the return data in Step1 can be written as: response1.body.parameter name, or response1.header.parameter name.
[0106] For example, Step 1 needs to receive the param parameter (param) passed in by the front end, as well as the Authorization parameter.
[0107] For example, the forwarding path of Step 1 can be written as:
[0108] http: / / ip:port / getDataInfo1? param1={input.request.body.param}¶m2={input.request.header.Authorization};
[0109] For example, Step 2 receives the result parameter (result) returned in Step 1, and also receives the Authorization parameter passed in by the front end.
[0110] For example, the forwarding path of Step 2 can be written as:
[0111] http: / / ip:port / getDataInfo2? param1={response1.body.result}¶m2={input.request.header.Authorization}
[0112] It should be noted that “?” and “&” are both symbols in the above forwarding path, for example, they can indicate that the path is a dynamic link, etc., and the present invention is not limited to this.
[0113] Optionally, when the workflow information includes return data formats corresponding to each interface in the aggregate interface and a template for data processing of return data of each interface, the orchestration of the workflow information corresponding to the API service includes:
[0114] The formats of the returned data of the atomic services respectively provided by the interfaces in the aggregate interface and the template for performing data integration processing on all the returned data are configured.
[0115] Optionally, the format of the return data of the atomic service provided by each interface in the aggregation interface can be configured, and the format may include the category, name, identification ID of each data, the user identification of the corresponding user, the user information of the corresponding user, the generation time, the generated version number, etc.; the data that can be applied to the business and the related information of the data are applicable to the present invention, which is not limited here. The user can determine it based on business needs, experience, industry default, or industry protocol. For example, the format of the data can be configured as follows:
[0116] Atomic service API1, the returned data is called json1, and the content is as follows:
[0117]
[0118] Atomic service API2, the returned data is called json2, and the content is as follows:
[0119]
[0120] Atomic service API3, the returned data is called json3, and the content is as follows:
[0121]
[0122]
[0123] That is, the returned Json in each Step can be processed based on the above format. The gateway will finally integrate the processed data and return the final data to the front end. The integration processing template can be to arrange all the data in sequence, and can also be configured to delete redundant data or privacy data;
[0124] Figure 3 This is the third flow chart of the data aggregation method based on API gateway provided by the present invention, such as Figure 3 As shown, for example, the data can be integrated first as follows:
[0125]
[0126]
[0127] Optionally, you can also perform field filtering: you can configure the atomic service interface output parameter blacklist in the integration processing template to exclude certain fields. For example, configure the blacklist [data.id] in the API3 output parameter. After gateway processing, the actual returned data is as follows, and you can see that the id field in the data object has been filtered out:
[0128]
[0129] Optionally, you can also perform field unpacking. You can configure in the integration processing template to extract the content of the specified object as the return result. The matching target can only be object. When the matching target is empty, the result is {}. After gateway processing, the actual returned data is as follows. You can see that the data object is unpacked, and the final data only retains the fields in the data object:
[0130]
[0131] Optionally, you can also package the data. You can configure the integration processing template to package the current data as an object in the final return data. You can configure it not to support arrays. After the gateway processes, the data can be packaged as an imageInfo object, and the original data can be turned into the final data result.
[0132] Optionally, when the workflow information includes the format of the output parameter of the aggregation interface, the orchestration of the workflow information corresponding to the API service includes:
[0133] Configure the format of the response header and response body for the output parameter.
[0134] Optionally, since the aggregation interface can execute corresponding steps based on the workflow information after receiving the request from the front end (such as input parameters) to obtain the data result after aggregation processing, it can respond to the front end (such as the dispatcher), and the response may include the data result after the above aggregation processing;
[0135] Optionally, the format of the response header and response body of the output parameters may be configured, for example, the response body may include the data result after the above aggregation processing;
[0136] Among them, the user can determine the format of the response header and response body of the output parameter according to business needs and experience, or industry default, or based on industry protocols, and all output parameters of the aggregation interface adopt this format.
[0137] Optionally, when the workflow information includes a feedback mode of a call result of the aggregation interface and a format of the feedback information, the arranging the workflow information corresponding to the API service includes:
[0138] In the case where the aggregate interface fails to call, the feedback method of the call result of the aggregate interface includes: putting the reason for the call failure into the message field of the context;
[0139] Configure the message format of the feedback information.
[0140] Optionally, if after receiving the request from the front end, when executing the corresponding steps based on the workflow information, one of the steps cannot be implemented due to request failure, the result of the call failure can be fed back to the caller; therefore, the feedback method of the call result of the aggregation interface and the format of the feedback information can also be configured;
[0141] Optionally, when a call fails, the reason for the call failure can be configured to be placed in the message field of the context. Users can also customize the message format returned to the caller based on business needs, experience, industry defaults, or industry protocols, and support customized response headers.
[0142] Compared with the traditional architecture, the present invention realizes a microservice architecture, in which the business system can rely on the collaboration between microservices to realize a complete business process, and the collaboration between microservices is service orchestration. The present invention uses the service orchestration method of the API gateway to quickly obtain the required data from various services, achieve rapid response to the business, and adapt and compatibility with the service data, which is conducive to reducing the interaction cost between the service provider and the caller, and making the entire process of service call more complete and efficient.
[0143] The API gateway-based service orchestration method provided by the present invention uses service aggregation / splitting to uniformly manage entrances, aggregates atomic service data, and encapsulates to create new services, which greatly reduces service call costs and business system response speeds, and can also improve the delivery efficiency of business system products.
[0144] The data aggregation device based on API gateway provided by the present invention is described below. The data aggregation device based on API gateway described below and the data aggregation method based on API gateway described above can refer to each other.
[0145] Figure 4 is a schematic diagram of the structure of the data aggregation device based on the API gateway provided by the present invention, such as Figure 4 As shown, the data aggregation device 400 based on the API gateway includes: a creation module 410 and an orchestration module 420; wherein:
[0146] The creation module 410 is used to create an API service in the API gateway based on business requirements, and the API service is implemented through an aggregate interface;
[0147] The orchestration module 420 is used to orchestrate the workflow information corresponding to the API service so that the output of the aggregation interface meets the business requirements;
[0148] The workflow information includes at least one of the following:
[0149] The format of the input parameters of the aggregation interface;
[0150] The calling step of the aggregation interface;
[0151] The format of the atomic service interface input and output parameters of the aggregate interface;
[0152] The return data formats corresponding to the interfaces in the aggregate interface and the templates for processing the return data of the interfaces;
[0153] The format of the output parameters of the aggregation interface;
[0154] The feedback method of the calling result of the aggregation interface and the format of the feedback information.
[0155] The data aggregation device based on API gateway provided in the embodiment of the present application can implement the various processes implemented by the above-mentioned method embodiments and achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0156] The data aggregation device based on API gateway provided by the present invention creates API service in API gateway based on business needs, that is, performs aggregation interface, and arranges the format of input parameters of the aggregation interface, calling steps, the format of input and output parameters of atomic service interface, the return data format corresponding to each interface and the template for data processing of the return data of each interface, the format of output parameters, the feedback method of calling result and the format of feedback information, and proposes a method for building a framework of business system, which can efficiently adjust the framework of business system based on business needs, make system applications and services easier to develop, upgrade, expand and deploy, and improve the development efficiency of business system products.
[0157] Figure 5 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the data aggregation method based on the API gateway, the method comprising: based on business needs, creating an API service in the API gateway, the API service being implemented through an aggregation interface;
[0158] Arrange the workflow information corresponding to the API service so that the output of the aggregation interface meets the business requirements;
[0159] The workflow information includes at least one of the following:
[0160] The format of the input parameters of the aggregation interface;
[0161] The calling step of the aggregation interface;
[0162] The format of the atomic service interface input and output parameters of the aggregate interface;
[0163] The return data formats corresponding to the interfaces in the aggregate interface and the templates for processing the return data of the interfaces;
[0164] The format of the output parameters of the aggregation interface;
[0165] The feedback method of the calling result of the aggregation interface and the format of the feedback information.
[0166] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0167] On the other hand, the present invention also provides a computer program product, the computer program product includes a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the data aggregation method based on the API gateway provided by the above methods, the method includes: based on business needs, creating an API service in the API gateway, the API service is implemented through an aggregation interface;
[0168] Arrange the workflow information corresponding to the API service so that the output of the aggregation interface meets the business requirements;
[0169] The workflow information includes at least one of the following:
[0170] The format of the input parameters of the aggregation interface;
[0171] The calling step of the aggregation interface;
[0172] The format of the atomic service interface input and output parameters of the aggregate interface;
[0173] The return data formats corresponding to the interfaces in the aggregate interface and the templates for processing the return data of the interfaces;
[0174] The format of the output parameters of the aggregation interface;
[0175] The feedback method of the calling result of the aggregation interface and the format of the feedback information.
[0176] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the data aggregation method based on the API gateway provided by the above methods, the method comprising: based on business needs, creating an API service in the API gateway, the API service being implemented through an aggregation interface;
[0177] Arrange the workflow information corresponding to the API service so that the output of the aggregation interface meets the business requirements;
[0178] The workflow information includes at least one of the following:
[0179] The format of the input parameters of the aggregation interface;
[0180] The calling step of the aggregation interface;
[0181] The format of the atomic service interface input and output parameters of the aggregate interface;
[0182] The return data formats corresponding to the interfaces in the aggregate interface and the templates for processing the return data of the interfaces;
[0183] The format of the output parameters of the aggregation interface;
[0184] The feedback method of the calling result of the aggregation interface and the format of the feedback information.
[0185] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0186] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0187] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data aggregation method based on API gateway, characterized in that: include: Based on business needs, create an API service in the API gateway, and the API service is implemented through an aggregate interface; wherein, first create a new API service in the API gateway, and specify the service name, authentication method, request protocol, request method, request path, input parameter request mode, error code definition, and parameter type information; Arrange the workflow information corresponding to the API service so that the output of the aggregation interface meets the business requirements; The workflow information includes: The format of the input parameters of the aggregation interface; The calling step of the aggregation interface; The format of the atomic service interface input and output parameters of the aggregate interface; The return data formats corresponding to the interfaces in the aggregate interface and the templates for processing the return data of the interfaces; The format of the output parameters of the aggregation interface; The feedback mode of the call result of the aggregation interface and the format of the feedback information; when the workflow information includes the format of the input parameters of the aggregation interface, the arrangement of the workflow information corresponding to the API service includes: Configuring the input parameter format includes: request header, request body and Query parameters; In a case where the workflow information includes the calling step, the orchestration of the workflow information corresponding to the API service includes: Configuring multiple steps included in the calling step, wherein each step includes a calling request of one or more interfaces, and the calling requests of one or more interfaces in each step are executed in parallel; Configuring a serial execution order between the multiple steps; Configure the request address, input parameters, data processing method, and call timeout time corresponding to each step; In the case where the workflow information includes the format of the input and output parameters of the atomic service interface, the arranging the workflow information corresponding to the API service includes: The format of configuring the input and output parameters of each atomic service interface in the aggregate interface includes: fixed value or reference value; In a case where the workflow information includes return data formats corresponding to the interfaces in the aggregate interface and templates for processing the return data of the interfaces, the arranging of the workflow information corresponding to the API service includes: Configuring the format of the return data of the atomic services provided by each interface in the aggregate interface, and a template for data integration processing of all the return data; In a case where the workflow information includes the format of the output parameter of the aggregation interface, the arranging the workflow information corresponding to the API service includes: Configure the format of the response header and response body of the output parameter; In the case where the workflow information includes a feedback mode of a call result of the aggregation interface and a format of the feedback information, the arranging of the workflow information corresponding to the API service includes: In the case where the aggregate interface fails to call, the feedback method of the call result of the aggregate interface includes: putting the reason for the call failure into the message field of the context; Configure the message format of the feedback information.
2. A data aggregation device based on API gateway, characterized in that: include: A creation module is used to create an API service in the API gateway based on business needs. The API service is implemented through an aggregate interface. A new API service is first created in the API gateway, and the service name, authentication method, request protocol, request method, request path, input parameter request mode, error code definition, and parameter type information are specified. An orchestration module, used to orchestrate the workflow information corresponding to the API service so that the output of the aggregation interface meets the business requirements; The workflow information includes: The format of the input parameters of the aggregation interface; The calling step of the aggregation interface; The format of the atomic service interface input and output parameters of the aggregate interface; The return data formats corresponding to the interfaces in the aggregate interface and the templates for processing the return data of the interfaces; The format of the output parameters of the aggregation interface; The feedback method of the calling result of the aggregation interface and the format of the feedback information; In a case where the workflow information includes the format of the input parameters of the aggregation interface, the arranging the workflow information corresponding to the API service includes: Configuring the input parameter format includes: request header, request body and Query parameters; In a case where the workflow information includes the calling step, the orchestration of the workflow information corresponding to the API service includes: Configuring multiple steps included in the calling step, wherein each step includes a calling request of one or more interfaces, and the calling requests of one or more interfaces in each step are executed in parallel; Configuring a serial execution order between the multiple steps; Configure the request address, input parameters, data processing method, and call timeout time corresponding to each step; In the case where the workflow information includes the format of the input and output parameters of the atomic service interface, the arranging the workflow information corresponding to the API service includes: The format of configuring the input and output parameters of each atomic service interface in the aggregate interface includes: fixed value or reference value; In a case where the workflow information includes return data formats corresponding to the interfaces in the aggregate interface and templates for processing the return data of the interfaces, the arranging of the workflow information corresponding to the API service includes: Configuring the format of the return data of the atomic services provided by each interface in the aggregate interface, and a template for data integration processing of all the return data; In a case where the workflow information includes the format of the output parameter of the aggregation interface, the arranging the workflow information corresponding to the API service includes: Configure the format of the response header and response body of the output parameter; In the case where the workflow information includes a feedback mode of a call result of the aggregation interface and a format of the feedback information, the arranging of the workflow information corresponding to the API service includes: In the case where the aggregate interface fails to call, the feedback method of the call result of the aggregate interface includes: putting the reason for the call failure into the message field of the context; Configure the message format of the feedback information.
3. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the data aggregation method based on the API gateway as described in claim 1 is implemented.
4. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, the data aggregation method based on the API gateway as claimed in claim 1 is implemented.
Citation Information
Patent Citations
Micro-service arrangement and data aggregation method based on Spring Clustered gateway
CN111818182A
API aggregation and data processing method and system based on interface description language
CN112130935A
Service calling method and system based on access gateway
CN112243032A
Service orchestration method based on API gateway
CN114416314A
Aggregating requests among microservices
US20180365087A1
