CN117667304A - Gateway system expansion method, device and storage medium - Google Patents

Gateway system expansion method, device and storage medium Download PDF

Info

Publication number
CN117667304A
CN117667304A CN202311619468.4A CN202311619468A CN117667304A CN 117667304 A CN117667304 A CN 117667304A CN 202311619468 A CN202311619468 A CN 202311619468A CN 117667304 A CN117667304 A CN 117667304A
Authority
CN
China
Prior art keywords
request
script
target
gateway system
engine component
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311619468.4A
Other languages
Chinese (zh)
Inventor
陈旭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tianyi Electronic Commerce Co Ltd
Original Assignee
Tianyi Electronic Commerce Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tianyi Electronic Commerce Co Ltd filed Critical Tianyi Electronic Commerce Co Ltd
Priority to CN202311619468.4A priority Critical patent/CN117667304A/en
Publication of CN117667304A publication Critical patent/CN117667304A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses a gateway system expansion method, a gateway system expansion device and a storage medium. Wherein the method comprises the following steps: acquiring a target request; processing the target request by adopting a script engine component embedded in the gateway system to obtain request information, wherein the script engine component is provided with a script interface, a plurality of execution scripts are uploaded to the script engine component through the script interface, and the plurality of execution scripts are respectively used for executing different processing functions; determining a target script corresponding to the request information in a plurality of execution scripts; and processing by adopting the target script based on the request information to obtain the request response of the target request. The invention solves the technical problems of increased cost and risk of developing operation and maintenance caused by the need of modifying the source code of the gateway system or redeploying the gateway system in the related technology.

Description

Gateway system expansion method, device and storage medium
Technical Field
The present invention relates to the field of software development, and in particular, to a gateway system extension method, device and storage medium.
Background
With development and application of micro-service architecture, the functional requirements of the gateway system are more and more diversified and complicated, and different users and scenes may have different customization and expansion requirements, for example, conversion and adaptation of data formats, protocol types, coding modes and the like of requests and responses, or realization of functions of business logic, data analysis, cache optimization and the like. The gateway system in the related art is usually based on static configuration files or databases to define and manage functions and rules of the gateway system, and this way is often inflexible and extensible when facing the needs of diversification and complexity, and needs to modify source codes of the gateway system or redeploy the gateway system, which increases development and operation costs and risks.
In view of the above problems, no effective solution has been proposed at present.
Disclosure of Invention
The embodiment of the invention provides a gateway system expansion method, a gateway system expansion device and a storage medium, which at least solve the technical problems of increased cost and risk of developing operation and maintenance caused by the need of modifying the source code of a gateway system or redeploying the gateway system in the related technology.
According to an aspect of an embodiment of the present invention, there is provided a gateway system extension method, including: acquiring a target request; processing the target request by adopting a script engine component embedded in a gateway system to obtain request information, wherein the script engine component is provided with a script interface, a plurality of execution scripts are uploaded to the script engine component through the script interface, and the execution scripts are respectively used for executing different processing functions; determining a target script corresponding to the request information from the plurality of execution scripts; and processing by adopting the target script based on the request information to obtain the request response of the target request.
Optionally, before the acquiring the target request, the method further includes: identifying the gateway system and determining the requirement of the gateway system; determining a scripting language used by the scripting engine component based on the gateway system requirements; the method for processing the target request by adopting the script engine component embedded in the gateway system to obtain request information comprises the following steps: analyzing a request header of the target request by the script engine component by adopting the script language, determining metadata of the target request and issuing account authentication information of the target request; analyzing the request parameters of the target request, and determining the query parameters of the uniform resource locator included in the target request; analyzing the request body of the target request to determine the form data value of the target request; and obtaining the request information based on the metadata, the account authentication information, the query parameters and the form data value.
Optionally, the processing with the target script based on the request information to obtain a request response of the target request includes: invoking a predetermined instance in a predetermined virtual machine environment, wherein the predetermined virtual machine environment provides an operating environment of the scripting language for the scripting engine component; and operating the target script by adopting the preset instance, and processing based on the request information to obtain the request response.
Optionally, the processing is performed by adopting the target script based on the request information to obtain a request response of the target request, and the method further includes: under the condition that the script engine component has a binding variable function, acquiring a global variable of the target script in the process of processing the request information; and storing the global variable as a binding variable in the script engine component, wherein the binding variable is used for sharing other scripts except the target script in the plurality of execution scripts.
Optionally, the target script adopts a plurality of threads to process, and the processing, based on the request information, by adopting the target script to obtain a request response of the target request includes: and under the condition that the script engine component has a context variable, controlling the threads to call the context variable, and processing the request information to obtain the request response.
Optionally, before the obtaining the request response of the target request, the method further includes: capturing an abnormal code of the target script in the processing process of the request information under the condition that the target script is in operation error; and returning error information of the target request based on the abnormal code.
Optionally, the method further comprises: determining a plurality of initial execution scripts; performing security detection on the plurality of initial execution scripts, and determining that the plurality of initial execution scripts are the plurality of execution scripts under the condition that the plurality of initial execution scripts pass the security detection; uploading the plurality of execution scripts to the script engine component through the script interface.
Optionally, the method further comprises: and in response to the version rollback requirement of one script in the plurality of execution scripts, rolling back the current version of the one script to the previous version.
According to another aspect of the embodiment of the present invention, there is provided a gateway system extension apparatus, including: the first acquisition module is used for acquiring the target request; the analysis module is used for processing the target request by adopting a script engine component embedded in the gateway system to obtain request information, wherein the script engine component is provided with a script interface, a plurality of execution scripts are uploaded to the script engine component through the script interface, and the execution scripts are respectively used for executing different processing functions; a first determining module, configured to determine a target script corresponding to the request information from the plurality of execution scripts; and the processing module is used for processing by adopting the target script based on the request information to obtain the request response of the target request.
According to another aspect of embodiments of the present invention, there is provided a non-volatile storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform any one of the gateway system extension methods.
In the embodiment of the invention, the target request is acquired; processing the target request by adopting a script engine component embedded in a gateway system to obtain request information, wherein the script engine component is provided with a script interface, a plurality of execution scripts are uploaded to the script engine component through the script interface, and the execution scripts are respectively used for executing different processing functions; determining a target script corresponding to the request information from the plurality of execution scripts; and processing by adopting the target script based on the request information to obtain the request response of the target request. The method achieves the aim of integrating the script technology in the gateway system, achieves the technical effect of dynamically customizing and expanding the gateway system without modifying the source code of the gateway system or redeploying the gateway system, and further solves the technical problems of increased cost and risk of developing operation and maintenance caused by modifying the source code of the gateway system or redeploying the gateway system in the related technology.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiments of the invention and together with the description serve to explain the invention and do not constitute a limitation on the invention. In the drawings:
fig. 1 is a flowchart of an alternative gateway system extension method provided according to an embodiment of the present invention;
fig. 2 is a schematic diagram of an alternative gateway system extension method according to an embodiment of the present invention;
fig. 3 is a schematic diagram of an alternative gateway system extension device according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For convenience of description, the following will describe some terms or terms related to the embodiments of the present application:
scripts, which are a set of pre-written computer instructions or code for performing specific tasks or functions. The purpose of the script is to be executed directly by the interpreter or execution engine without the need to compile into machine code. The script is mainly used for scenes such as automation tasks, batch processing, data processing, system configuration and the like.
With development of cloud computing and container technology, more and more applications adopt cloud native architecture, and the scalability, reliability and maintainability of the applications are improved by using technologies such as micro services, service grids, no servers and the like. The custom script technology can provide a unified gateway system for the cloud native application, so that a user can write custom script codes according to different cloud platforms and service types, and flexible management and control of the cloud native application are realized.
With the popularization of the internet of things, more and more devices and sensors are connected to the internet, so that a huge internet of things network is formed. The custom script technology can provide an intelligent gateway system for the application of the Internet of things, so that a user can write custom script codes according to different equipment and sensor types, and real-time processing and analysis of the data of the Internet of things are realized.
A gateway system is a device or software that connects different networks or communication systems for data transfer and conversion between them to ensure that data can be efficiently interacted and communicated between the different systems. Gateway systems may be used to connect different computer networks, communication protocols, devices or applications to enable transmission, conversion and management of data. Are commonly used in intranets, the internet of things and other communication networks.
JavaScript allows a developer to embed and execute JavaScript code in a Java application, so that more flexible and dynamic functions are realized, and the JavaScript code can be realized through a Java built-in JavaScript engine or a third party JavaScript engine. The method can be used for developing various application scenes such as Web network application programs, server-side scripts, desktop application programs and the like.
In view of the foregoing, embodiments of the present invention provide an extended method embodiment for a gateway system, it should be noted that the steps illustrated in the flowchart of the figures may be performed in a computer system, such as a set of computer executable instructions, and that, although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order other than that illustrated herein.
Fig. 1 is a flowchart of an optional gateway system extension method according to an embodiment of the present invention, as shown in fig. 1, the method includes the following steps:
step S102, obtaining a target request;
it may be appreciated that the gateway system may obtain a target request from a client, where the client may interact with the server through the gateway system, and the client sends the target request to the gateway system, where the target request may include information about the server that needs to be accessed, or an operation that needs to be performed. The gateway system receives the request of the user terminal, analyzes and verifies the request to ensure that the request meets the specification and authority requirements, and then forwards the request to the corresponding server terminal according to the information contained in the target request, and a final target server terminal is determined possibly through mechanisms such as routing, load balancing and the like.
In an alternative embodiment, the method further comprises, prior to obtaining the request response of the target request: capturing an abnormal code of the target script in the process of processing the request information under the condition that the target script is in operation error; based on the exception code, error information of the target request is returned.
It will be appreciated that when the target script is used to process the request information, there may be a running error, and it is necessary to capture the abnormal code of the target script in which the error occurs. By using the exception handling mechanism, possible exceptions can be captured and handled in time. Based on the captured exception code, error information is generated, which may be returned to the caller or to the user. Through the processing, an exception capturing mechanism is added, so that error processing measures such as rollback operation can be performed in time. It should be noted that, the specific manner of capturing the exception and handling the error may be different depending on the programming language, framework or script engine used, and is not limited in particular.
Optionally, after the exception code is captured, a log file may also be written, stored in a memory variable, or transferred to other functions.
Step S104, processing the target request by adopting a script engine component embedded in the gateway system to obtain request information, wherein the script engine component is provided with a script interface, a plurality of execution scripts are uploaded to the script engine component through the script interface, and the plurality of execution scripts are respectively used for executing different processing functions;
it will be appreciated that as services evolve and change, new functions may need to be added or existing functions may need to be modified. In this case, the most straightforward method in the related art is to modify the source code of the gateway system and redeploy. Redeployment of gateway systems may result in service outages, which is an unacceptable problem in environments where service availability is critical, and modification of source code and redeployment may introduce new performance issues, requiring adequate testing to ensure that the new version of the gateway system is able to meet the performance requirements. Modifying source code is also a time consuming process requiring extensive development, testing and deployment effort. Therefore, the script engine component embedded in the gateway system is adopted to process the target request, the target request can be dynamically processed, and the script can be flexibly written according to the service requirement so as to realize new functions or expand the existing functions. This means that when traffic demands change, these changes can be accommodated by writing new scripts without modifying the source code of the gateway system or redeploying the system. The uploading of the script to the script engine component may be accomplished through a script interface, with multiple execution scripts being used to execute different processing functions, respectively.
Alternatively, the script interface may be Java Scripting API, which is an application interface of a Java script.
Alternatively, multiple execution scripts may be uploaded into a specified target or location through the scripting interface, and once the execution scripts are uploaded successfully, the script engine component may load the execution scripts to process the target request according to its defined processing logic.
In an alternative embodiment, the method further comprises, prior to obtaining the target request: identifying a gateway system and determining the requirement of the gateway system; determining a scripting language used by the scripting engine component based on gateway system requirements; processing the target request by adopting a script engine component embedded in the gateway system to obtain request information, wherein the method comprises the following steps: the script engine component adopts a script language to analyze the request header of the target request, determine the metadata of the target request and send out the account authentication information of the target request; analyzing request parameters of the target request, and determining query parameters of the uniform resource locator included in the target request; analyzing a request body of the target request to determine a form data value of the target request; based on the metadata, account authentication information, query parameters, and form data values, request information is obtained.
It will be appreciated that it is critical to identify and determine the requirements of the gateway system to help ensure that the selected script engine components match the gateway system. The scripting language used by the scripting engine component is determined based on the requirements of the gateway system, facilitating customized processing logic to meet the specific requirements of the gateway system. The script engine component analyzes the target request by adopting a script language, and is used for determining a request head, request parameters and information included in a request body, and obtaining the request information based on metadata, account authentication information, query parameters and form data values.
Optionally, a request header for parsing the target request may also be available, such as a request method, a request path, a request protocol version, and the like. The type and direction of the target request, as well as the source and destination of the request, may be determined by parsing the request header. Specific fields in the request header, such as a Cookie (a small text file) or HTTP (Hypertext Transfer Protocol ) header, may also be parsed from which account authentication information for the outgoing target request may be extracted.
Optionally, metadata of the target request is determined, and information such as: the source IP (Internet Protocol ) address of the source client of the target request, the timestamp of the target request, the client agent of the target request, etc., which may be used for subsequent processing or recording.
Alternatively, for requests containing query parameters, such as URL (uniform resource locator) parameters in GET requests, the script engine component can interpret the request parameters. The GET request is a request method in the HTTP protocol, and is used to request the server to obtain the information of the specified resource. By involving reading the query string in the URL and parsing out the values of the various parameters, specific parameter information in the request can be extracted for subsequent processing or querying.
Alternatively, the requestor is a data portion contained in the HTTP request, typically used to send data, such as form data values, JSON data, etc., to the server. JSON (JavaScript Object Notation) is a data format commonly used to transfer data in HTTP request bodies. JSON data is typically a collection of key-value pairs, represented in the form of objects, with the requestor typically located in a body portion of the request separate from the request header.
Alternatively, the gateway system requirement may be multiple, for example, the gateway system requirement in terms of technical architecture, interface, and communication protocol. Functional requirements of the network system may be included, and the ability of selected script engine components to specifically handle those requirements may be ensured. If the gateway system needs to handle a large number of concurrent requests, then the selected script engine component should be able to support high performance and high concurrency.
Alternatively, the scripting language may be multiple, such as: the crawler Python language, javaScript language, etc., preferably JavaScript language can be used.
Step S106, determining a target script corresponding to the request information in a plurality of execution scripts;
it will be appreciated that the target script for processing the target request may be determined from among a plurality of execution scripts according to the request information.
Step S108, processing is carried out by adopting a target script based on the request information, and a request response of the target request is obtained.
It can be appreciated that, for the request information parsed in the target request, the target script is adopted to process, so as to generate a request response to the target request. The request response may be a response to the client or the server.
Alternatively, the target script may perform a plurality of processing functions, for example: caching of scripts, precompiled, hot loading, performance monitoring and the like. The caching of the script is used to cache intermediate representations of the script or compiled code so that the execution process can be accelerated in subsequent executions. Scripts are precompiled for converting script code into machine code or other forms of intermediate representations to improve execution efficiency. A hot load function for allowing dynamic loading and execution of new script code. And the performance monitoring function is used for monitoring the execution performance of the script, such as indexes of CPU, memory consumption, execution time and the like.
In an alternative embodiment, processing with the target script based on the request information to obtain a request response of the target request includes: invoking a predetermined instance in a predetermined virtual machine environment, wherein the predetermined virtual machine environment provides a scripting language running environment for the scripting engine component; and operating the target script by adopting a preset instance, and processing based on the request information to obtain a request response.
It will be appreciated that launching a predetermined instance in a particular virtual machine environment may also be referred to as a cloud instance. The scripting engine component is provided with a scripting language running environment within this predetermined virtual machine environment. The predetermined instance in the predetermined virtual machine environment is used for running the target script, and when the target script is run, the predetermined instance processes based on the request information and is used for obtaining the request response.
Alternatively, the predetermined instance may be an instance of a GraalVM, and the instance of the GraalVM may be a GraalVM virtual machine environment running in a predetermined virtual machine environment, where the GraalVM virtual machine environment is a high-performance multi-language virtual machine and a runtime environment, and supports running multiple languages in the same runtime environment, including JavaScript, python, etc. In the case where the scripting languages are multiple, the predetermined virtual machine environment may provide interoperability between multiple languages, and functions and data may be invoked seamlessly between different languages. For building embedded applications, e.g. running in an embedded device or IoT (internet of things) device.
In an alternative embodiment, the processing is performed by using a target script based on the request information to obtain a request response of the target request, and the method further includes: under the condition that the script engine component has a binding variable function, acquiring a global variable of the target script in the process of processing the request information; the global variable is stored as a binding variable in the script engine component, wherein the binding variable is used for sharing other scripts in the plurality of execution scripts except the target script.
It will be appreciated that some global variables may be created or modified during execution of the target script, which may be to meet data sharing, state management, or other requirements during script execution. These global variables can be captured and stored through the bind variable function of the script engine component. Once global variables are obtained, they can be stored as binding variables in the script engine component for sharing and accessing these global variables among other scripts. By storing global variables as binding variables, other scripts can place and call the values of these global variables. Through the processing, the binding variable is used as a bridge for data sharing among a plurality of execution scripts, so that the repeated creation and updating of the value of the global variable among the plurality of execution scripts can be avoided, and the code reusability and maintainability are improved.
In an alternative embodiment, the target script is processed by a plurality of threads, and based on the request information, the target script is processed to obtain a request response of the target request, including: in the case that the script engine component has a context variable, a plurality of threads are controlled to call the context variable, and request information is processed to obtain a request response.
It will be appreciated that when the target script is processed using multiple threads and the script engine component has context variables, the request information can be processed and a request response can be obtained by controlling the multiple threads to invoke the context variables. Creating a context variable in the script engine component can share and access among multiple threads, create or allocate threads for processing, and can process multiple requests in parallel, thereby improving processing efficiency. The threads may use context variables to store and retrieve request information, as well as to share data during processing. Because multiple threads execute concurrently, synchronization and communication between threads may be required to ensure consistency and correctness of data, and coordination between threads is achieved. Through the processing, the request response can be obtained by controlling the multiple threads to call the context variables to process the request information.
Alternatively, multiple threads of the target script call may use synchronization primitives, such as condition variables, each having a boolean variable associated with it, which the thread may use to check whether a condition is met, thus adapting to a thread call scenario that requires waiting for a condition to be met. Coordination between multiple threads may also be achieved using inter-thread communication mechanisms, such as message queues.
In an alternative embodiment, the method further comprises: determining a plurality of initial execution scripts; performing security detection on the plurality of initial execution scripts, and determining the plurality of initial execution scripts as a plurality of execution scripts under the condition that the plurality of initial execution scripts pass the security detection; and uploading the plurality of execution scripts to the script engine component through the script interface.
It will be appreciated that the plurality of initial execution scripts may come from different sources, including but not limited to a code base, user input, or other system. It is critical that security checks be made between execution scripts, after which multiple execution scripts pass the security check, it can be determined that no known vulnerabilities can be exploited, after which the multiple execution scripts are uploaded to the script engine component.
Alternatively, the above security detection may be various, for example: through static code analysis, it is detected whether the initial execution script only has necessary rights, and the rights are properly set and managed. And the sandbox operation can be performed, the initial execution script is operated in a virtual machine or an isolation sandbox, the behavior and the output result of the initial execution script are observed, and then the safety detection result of the initial execution script is determined.
In an alternative embodiment, the method further comprises: in response to a version rollback requirement of one script of the plurality of execution scripts, a current version of the one script is rolled back to a previous version.
It will be appreciated that if a request is received to rollback a script version, feedback from the user side, analysis reports of error information, or other system notifications may be received. The current version is rolled back using the last version of data stored in the gateway system data. Through the processing, a version rollback function is provided for the script engine component embedded in the gateway system, and if the current version is wrong or abnormal, the script engine component can roll back to the correct previous version, so that data loss and system breakdown are prevented, and the integrity and usability of the data are ensured.
Alternatively, the current version and the previous version may be distinguished by the version number of the script, the creation time, the modification record, etc.
Optionally, after the version rollback is completed, a verification process may also be performed to ensure the correctness and stability of the script, such as with a verification module integrated in the gateway system.
Through the step S102, a target request is acquired; step S104, processing the target request by adopting a script engine component embedded in the gateway system to obtain request information, wherein the script engine component is provided with a script interface, a plurality of execution scripts are uploaded to the script engine component through the script interface, and the plurality of execution scripts are respectively used for executing different processing functions; step S106, determining a target script corresponding to the request information in a plurality of execution scripts; step S108, processing is carried out by adopting a target script based on the request information, and a request response of the target request is obtained. The method can realize the purpose of integrating the script technology in the gateway system, realize the technical effect of dynamically customizing and expanding the gateway system without modifying the source code of the gateway system or redeploying the gateway system, and further solve the technical problems of the prior art that the source code of the gateway system is required to be modified or the gateway system is redeployed, resulting in the increase of the cost and risk of developing operation and maintenance.
Based on the foregoing embodiments and optional embodiments, an optional implementation manner is provided in the present invention, and fig. 2 is a schematic diagram of an optional gateway system extension method provided in accordance with an embodiment of the present invention, as shown in fig. 2, in the gateway system, a script execution engine component is embedded, which is used to execute script processing such as script caching, precompiled, and hot loading. So that a user can dynamically customize and extend the functionality and rules of the gateway system using the scripting language without modifying the source code of the gateway system or redeploying the gateway system. The plurality of execution scripts for executing the different processing functions uploaded to the gateway system through the script interface may be stored in a database in the gateway system. The back-end unified management page interacts with the gateway system, and a script management module is used for uploading and rolling back scripts, so that script execution can be distributed and scheduled for the request. The script management module may provide verification, version control, rights control, error handling, etc. of the script. The script execution module in the gateway system is adopted to process the request information of the target request and return the execution result to the server of the user side or the back end.
By integrating a script execution engine component in the gateway system, a plurality of execution scripts can be parsed and executed by selecting JavaScript as the scripting language of the gateway system. Instances of GraalVM are created and managed in the gateway system using Java Scripting API as a scripting interface, providing a scripting language running environment for scripting engine components in accordance with the GraalVM virtual machine environment. An instance of GraalVM is employed to run scripts and provide functions such as binding variables, setting contexts, handling exceptions, etc.
The script management module is used for managing a plurality of execution scripts and distributing and scheduling the execution of the scripts. The script management module may provide functions such as verification of scripts, version control, rights control, error handling, etc. And the script execution module in the gateway system is used for selecting and calling the target script according to the user request and the configuration rule, and returning the execution result of the target request to the user end or forwarding the execution result to a server at the back end. The script execution module can provide functions of script caching, precompilation, hot loading, performance monitoring and the like. By utilizing the script management module and the script execution module, a user can quickly develop and test script codes and dynamically update and execute scripts to meet personalized business requirements.
At least the following effects are achieved by the above alternative embodiments: it is achieved that the functionality and rules of the gateway system can be dynamically customized and extended using the scripting language without the need to modify the source code of the gateway system or reconfigure the gateway system. The own script code is developed and tested quickly and can be updated and published dynamically without restarting the gateway system or affecting other users. The method can efficiently process the user request by utilizing the characteristics of high performance and low resource consumption of the script language, and can avoid negative influence of the script code on the gateway system by utilizing the isolation mechanism of the script engine.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
The embodiment also provides a gateway system extension device, which is used for implementing the foregoing embodiments and preferred embodiments, and is not described in detail. As used below, the terms "module," "apparatus" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
According to an embodiment of the present invention, there is further provided an embodiment of an apparatus for implementing a gateway system extension method, and fig. 3 is a schematic diagram of a gateway system extension apparatus according to an embodiment of the present invention, as shown in fig. 3, where the gateway system extension apparatus includes: the first obtaining module 302, the parsing module 304, the first determining module 306, the processing module 308, and the apparatus will be described below.
A first obtaining module 302, configured to obtain a target request;
the parsing module 304 is connected to the first obtaining module 302, and is configured to process the target request by using a script engine component embedded in the gateway system to obtain request information, where the script engine component has a script interface, multiple execution scripts are uploaded to the script engine component through the script interface, and the multiple execution scripts are respectively used to execute different processing functions;
a first determining module 306, connected to the parsing module 304, for determining a target script corresponding to the request information from the plurality of execution scripts;
the processing module 308 is connected to the first determining module 306, and is configured to perform processing with the target script based on the request information, so as to obtain a request response of the target request.
In the gateway system expansion device provided by the embodiment of the invention, a first obtaining module 302 is used for obtaining a target request; the parsing module 304 is connected to the first obtaining module 302, and is configured to process the target request by using a script engine component embedded in the gateway system to obtain request information, where the script engine component has a script interface, multiple execution scripts are uploaded to the script engine component through the script interface, and the multiple execution scripts are respectively used to execute different processing functions; a first determining module 306, connected to the parsing module 304, for determining a target script corresponding to the request information from the plurality of execution scripts; the processing module 308 is connected to the first determining module 306, and is configured to perform processing with the target script based on the request information, so as to obtain a request response of the target request. The method achieves the aim of integrating the script technology in the gateway system, achieves the technical effect of dynamically customizing and expanding the gateway system without modifying the source code of the gateway system or redeploying the gateway system, and further solves the technical problems of increased cost and risk of developing operation and maintenance caused by modifying the source code of the gateway system or redeploying the gateway system in the related technology.
As an optional embodiment, the gateway system extension device provided in the embodiment of the present invention further includes: identifying a gateway system and determining the requirement of the gateway system; determining a scripting language used by the scripting engine component based on gateway system requirements; an parsing module comprising: the request header analysis module is used for analyzing the request header of the target request by adopting a script language by the script engine component, determining the metadata of the target request and sending out account authentication information of the target request; the request parameter analysis module is used for analyzing the request parameters of the target request and determining the query parameters of the uniform resource locator included in the target request; the request body analysis module is used for analyzing a request body of the target request and determining form data values of the target request; and the request information generation module is used for obtaining the request information based on the metadata, the account authentication information, the query parameters and the form data value.
As an optional embodiment, the gateway system extension device provided by the embodiment of the present invention, a request information generating module, includes: the calling module is used for calling a preset instance in a preset virtual machine environment, wherein the preset virtual machine environment provides a script engine component with a script language running environment; and the script processing module is used for running a target script by adopting a preset instance, and processing the target script based on the request information to obtain a target request response.
As an optional embodiment, the gateway system extension device provided in the embodiment of the present invention, the processing module includes: the variable acquisition module is used for acquiring global variables of the process of processing the request information by the target script under the condition that the script engine component has a bound variable function; and the binding variable module is used for storing the global variable as a binding variable in the script engine component, wherein the binding variable is used for sharing other scripts except the target script in the plurality of execution scripts.
As an optional embodiment, the gateway system extension device provided in the embodiment of the present invention, the processing module includes: and the parallel processing module is used for controlling the threads to call the context variables under the condition that the script engine component has the context variables, and processing the request information to obtain a request response.
As an optional embodiment, the gateway system extension device provided in the embodiment of the present invention further includes: the exception capturing module is used for capturing exception codes of the target script in the process of processing the request information under the condition that the target script is in operation error; and the error information return module is used for returning the error information of the target request based on the abnormal code.
As an optional embodiment, the gateway system extension device provided in the embodiment of the present invention further includes: the initial script determining module is used for determining a plurality of initial execution scripts; the safety detection module is used for carrying out safety detection on the plurality of initial execution scripts, and determining the plurality of initial execution scripts as a plurality of execution scripts under the condition that the plurality of initial execution scripts pass the safety detection; and the script uploading module is used for uploading the plurality of execution scripts to the script engine component through the script interface.
As an optional embodiment, the gateway system extension device provided in the embodiment of the present invention further includes: and the rollback module is used for responding to the version rollback requirement of one script in the plurality of execution scripts and rolling back the current version of the one script to the previous version.
It should be noted that each of the above modules may be implemented by software or hardware, for example, in the latter case, it may be implemented by: the above modules may be located in the same processor; alternatively, the various modules described above may be located in different processors in any combination.
It should be noted that, the first obtaining module 302, the parsing module 304, the first determining module 306, and the processing module 308 correspond to steps S102 to S108 in the embodiment, and the modules are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the disclosure of the embodiment. It should be noted that the above modules may be run in a computer terminal as part of the apparatus.
It should be noted that, the optional or preferred implementation manner of this embodiment may be referred to the related description in the embodiment, and will not be repeated herein.
The gateway system extension device may further include a processor and a memory, where the first obtaining module 302, the parsing module 304, the first determining module 306, the processing module 308, and the like are stored as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel may be provided with one or more. The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
The embodiment of the invention provides a nonvolatile storage medium, on which a program is stored, which when executed by a processor, implements a gateway system extension method.
The embodiment of the invention provides an electronic device, which comprises a processor, a memory and a program stored on the memory and capable of running on the processor, wherein the following steps are realized when the processor executes the program: acquiring a target request;
Processing the target request by adopting a script engine component embedded in the gateway system to obtain request information, wherein the script engine component is provided with a script interface, a plurality of execution scripts are uploaded to the script engine component through the script interface, and the plurality of execution scripts are respectively used for executing different processing functions; determining a target script corresponding to the request information in a plurality of execution scripts; and processing by adopting the target script based on the request information to obtain the request response of the target request. The device herein may be a server, a PC, etc.
The invention also provides a computer program product adapted to perform, when executed on a data processing device, a program initialized with the method steps of: acquiring a target request; processing the target request by adopting a script engine component embedded in the gateway system to obtain request information, wherein the script engine component is provided with a script interface, a plurality of execution scripts are uploaded to the script engine component through the script interface, and the plurality of execution scripts are respectively used for executing different processing functions; determining a target script corresponding to the request information in a plurality of execution scripts; and processing by adopting the target script based on the request information to obtain the request response of the target request.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The foregoing is merely exemplary of the present invention and is not intended to limit the present invention. Various modifications and variations of the present invention will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the invention are to be included in the scope of the claims of the present invention.

Claims (10)

1. A gateway system extension method, comprising:
acquiring a target request;
processing the target request by adopting a script engine component embedded in a gateway system to obtain request information, wherein the script engine component is provided with a script interface, a plurality of execution scripts are uploaded to the script engine component through the script interface, and the execution scripts are respectively used for executing different processing functions;
Determining a target script corresponding to the request information from the plurality of execution scripts;
and processing by adopting the target script based on the request information to obtain the request response of the target request.
2. The method of claim 1, wherein the step of determining the position of the substrate comprises,
before the acquiring the target request, the method further includes: identifying the gateway system and determining the requirement of the gateway system; determining a scripting language used by the scripting engine component based on the gateway system requirements;
the method for processing the target request by adopting the script engine component embedded in the gateway system to obtain request information comprises the following steps: analyzing a request header of the target request by the script engine component by adopting the script language, determining metadata of the target request and issuing account authentication information of the target request; analyzing the request parameters of the target request, and determining the query parameters of the uniform resource locator included in the target request; analyzing the request body of the target request to determine the form data value of the target request;
and obtaining the request information based on the metadata, the account authentication information, the query parameters and the form data value.
3. The method according to claim 2, wherein the processing with the target script based on the request information to obtain a request response of the target request includes:
invoking a predetermined instance in a predetermined virtual machine environment, wherein the predetermined virtual machine environment provides an operating environment of the scripting language for the scripting engine component;
and operating the target script by adopting the preset instance, and processing based on the request information to obtain the request response.
4. The method of claim 1, wherein the processing with the target script based on the request information results in a request response for the target request, the method further comprising:
under the condition that the script engine component has a binding variable function, acquiring a global variable of the target script in the process of processing the request information;
and storing the global variable as a binding variable in the script engine component, wherein the binding variable is used for sharing other scripts except the target script in the plurality of execution scripts.
5. The method of claim 1, wherein the target script is processed using a plurality of threads, and wherein the processing using the target script based on the request information results in a request response for the target request, comprising:
And under the condition that the script engine component has a context variable, controlling the threads to call the context variable, and processing the request information to obtain the request response.
6. The method of claim 1, wherein prior to the obtaining the request response to the target request, the method further comprises:
capturing an abnormal code of the target script in the processing process of the request information under the condition that the target script is in operation error;
and returning error information of the target request based on the abnormal code.
7. The method according to any one of claims 1 to 6, further comprising:
determining a plurality of initial execution scripts;
performing security detection on the plurality of initial execution scripts, and determining that the plurality of initial execution scripts are the plurality of execution scripts under the condition that the plurality of initial execution scripts pass the security detection;
uploading the plurality of execution scripts to the script engine component through the script interface.
8. The method according to any one of claims 1 to 6, further comprising:
And in response to the version rollback requirement of one script in the plurality of execution scripts, rolling back the current version of the one script to the previous version.
9. A gateway system extension apparatus, comprising:
the first acquisition module is used for acquiring the target request;
the analysis module is used for processing the target request by adopting a script engine component embedded in the gateway system to obtain request information, wherein the script engine component is provided with a script interface, a plurality of execution scripts are uploaded to the script engine component through the script interface, and the execution scripts are respectively used for executing different processing functions;
a first determining module, configured to determine a target script corresponding to the request information from the plurality of execution scripts;
and the processing module is used for processing by adopting the target script based on the request information to obtain the request response of the target request.
10. A non-volatile storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the gateway system extension method of any one of claims 1 to 8.
CN202311619468.4A 2023-11-29 2023-11-29 Gateway system expansion method, device and storage medium Pending CN117667304A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311619468.4A CN117667304A (en) 2023-11-29 2023-11-29 Gateway system expansion method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311619468.4A CN117667304A (en) 2023-11-29 2023-11-29 Gateway system expansion method, device and storage medium

Publications (1)

Publication Number Publication Date
CN117667304A true CN117667304A (en) 2024-03-08

Family

ID=90065468

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311619468.4A Pending CN117667304A (en) 2023-11-29 2023-11-29 Gateway system expansion method, device and storage medium

Country Status (1)

Country Link
CN (1) CN117667304A (en)

Similar Documents

Publication Publication Date Title
CN109002362B (en) Service method, device and system and electronic equipment
EP2798494B1 (en) Virtual channel for embedded process communication
US20190028360A1 (en) Visual devops systems and methods
US20210149648A1 (en) System and a method for automating application development and deployment
EP2153344B1 (en) Dynamically loading scripts
US9916137B2 (en) Rest service source code generation
JP2021518619A (en) Systems and methods for connector development and integrated channel deployment
US10318318B2 (en) Extending user interface of a web console
US20130160130A1 (en) Application security testing
US20030229665A1 (en) Systems, methods and computer programs for implementing and accessing web services
US20030149799A1 (en) System supporting unified event handling in ECMAScript
US9886366B2 (en) Replay-suitable trace recording by service container
CN106294113B (en) creation method and device based on programmable test service
US9218139B2 (en) Minimally disruptive virtual machine snapshots
US11210206B1 (en) Spoofing stateful dependencies during software testing
US7171650B2 (en) System and method for integrating resources in a network
Rajput Hands-On Microservices–Monitoring and Testing: A performance engineer’s guide to the continuous testing and monitoring of microservices
CN112860507B (en) Control method and device for sampling rate of distributed link tracking system
CN115113972A (en) Application transformation method, system, cluster, medium and program product
KR102337962B1 (en) System and method for executing application based on microservice architecture and computer program for the same
CN113179269A (en) Internet of things-based protocol data analysis method, system, medium, and program product
CN108496157B (en) System and method for providing runtime trace using an extended interface
CN110008086B (en) Log generation method and device and client
CN117667304A (en) Gateway system expansion method, device and storage medium
Schuette et al. Exploiting instruction-level resource parallelism for transparent, integrated control-flow monitoring

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination