CN117648356A - Inter-module interface calling method, device, equipment and readable medium - Google Patents

Inter-module interface calling method, device, equipment and readable medium Download PDF

Info

Publication number
CN117648356A
CN117648356A CN202311482005.8A CN202311482005A CN117648356A CN 117648356 A CN117648356 A CN 117648356A CN 202311482005 A CN202311482005 A CN 202311482005A CN 117648356 A CN117648356 A CN 117648356A
Authority
CN
China
Prior art keywords
interface
attribute
module
functional module
attribute description
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
CN202311482005.8A
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.)
Suzhou Metabrain Intelligent Technology Co Ltd
Original Assignee
Suzhou Metabrain Intelligent Technology 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 Suzhou Metabrain Intelligent Technology Co Ltd filed Critical Suzhou Metabrain Intelligent Technology Co Ltd
Priority to CN202311482005.8A priority Critical patent/CN117648356A/en
Publication of CN117648356A publication Critical patent/CN117648356A/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

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a method, a device, electronic equipment and a computer readable medium for calling interfaces among modules, wherein the method comprises the following steps: when a first function module initiates a call request to a first interface of a second function module, first data flow information output by the first interface of the first function module is stored in a Redis database, a release mechanism of the Redis database is called, the first data flow information is sent to a channel registered by the second function module through a pre-packaged release interface, and when a pre-packaged receiving interface monitors the first data flow information in the channel in a first procedure initiated by the second function module, an attribute table is called to perform data conversion on the first data flow information, and the first data flow information after data conversion is input into a second interface of the second function module. The remote calling of interfaces among different modules can be realized based on a publish-subscribe mechanism of the Redis database.

Description

Inter-module interface calling method, device, equipment and readable medium
Technical Field
The present invention relates to the field of process communications technologies, and in particular, to a method and an apparatus for calling an interface between modules, an electronic device, and a computer readable medium.
Background
Along with the continuous progress of technology, various communication modes among modules are continuously updated, and the communication modes such as shared memory, pipelines, signals, sockets, queues and the like of the traditional system and the relatively complex and various communication modes such as Dbus and the like for a desktop system are available, but among the communication modes, only one-way communication or communication in the modules can be realized, and interface remote call among the modules can not be realized at the same time.
Disclosure of Invention
In view of this, the application proposes a method, a device, an electronic device and a computer readable medium for calling interfaces between modules, which can realize remote calling of interfaces between different modules based on a publish-subscribe mechanism of a Redis database.
In a first aspect of the embodiments of the present application, there is provided a method for calling an interface between modules, where the method includes:
when a first function module initiates a first interface call request to a second function module, storing first data flow information output by a first interface of the first function module into a Redis database;
invoking a release mechanism of the Redis database, and sending the first data stream information to a channel registered by the second functional module through a pre-packaged release interface;
When a first thread initiated by a pre-packaged receiving interface in a second functional module monitors first data flow information in the channel, calling an attribute table to perform data conversion on the first data flow information;
and inputting the first data stream information after the data conversion into a second interface of the second functional module.
In one embodiment, when the prepackaged receiving interface monitors the first data flow information in the channel at the first thread initiated by the second functional module, the calling the attribute table to perform data conversion on the first data flow information includes:
invoking the attribute table to acquire a first interface attribute of the first interface and a second interface attribute of the second interface, acquiring a first data attribute description based on the first interface attribute, and acquiring a second data attribute description based on the second interface attribute;
analyzing the first data stream information according to the first data attribute description;
and carrying out data conversion on the parsed first data stream information according to the second data attribute description.
In one embodiment, after the first data flow information after the data conversion is input to the second interface of the second functional module, the method further includes:
Processing the first data stream information after data conversion through the second functional module to obtain second data stream information, and storing the second data stream information into a Redis database;
performing data conversion on the second data stream information according to the first data attribute description;
and calling a release mechanism of the Redis database, and sending the second data flow information after the data conversion to the first functional module through the release interface.
In one embodiment, the method further comprises:
constructing a tree structure;
obtaining module attributes, interface attributes and parameter attributes of each functional module, wherein the functional modules at least comprise the first functional module and the second functional module;
respectively constructing a corresponding attribute table based on the module attribute, the interface attribute and the parameter attribute, wherein the attribute table comprises a ModCode attribute description table, an IfcCode attribute description table and a parameter attribute description table;
and storing the attribute table correspondingly into the constructed tree structure.
In one embodiment, the ModCode attribute description table in the tree structure corresponds to the function modules one by one, where the ModCode attribute description table includes a module code of the function module, a first channel field, an ifcc code attribute description table pointer, and the number of ifcc code attribute description tables, where the ifcc code attribute description table pointer is used to point to the ifcc code attribute description table corresponding to the interface included in the function module;
The ifcc node attribute description table corresponds to the interfaces contained in the functional module one by one, wherein the ifcc node attribute description table comprises an interface code of the interface, a second channel field, a parameter attribute description table pointer, a parameter number and an interface function pointer, the parameter attribute description table pointer is used for pointing to the parameter attribute description table of the interface corresponding to the ifcc node attribute description table, and the interface function pointer is used for pointing to a function of the interface;
the parameter attribute description table corresponds to the parameters of the interface, and is used for being called by a plurality of the ifcc code attribute description tables, wherein the parameter attribute description table comprises a parameter type, a parameter length and a default value, and the default value is used for representing the initial value of each parameter included in the parameter attribute description table before being modified.
In one embodiment, after the storing the attribute table in the constructed tree structure, the method further includes:
acquiring a first channel field in the module attribute and a second channel field of the interface attribute, and splicing the first channel field and the second channel field to obtain channels registered by the functional modules;
In each functional module, an initiating thread monitors a channel registered by the functional module.
In one embodiment, the method further comprises:
when a first function module initiates a first interface call request to a second function module, the receiving interface initiates a second thread in the second function module;
the second thread is used for processing interface calling requests of other functional modules to the second functional module.
In a second aspect of the embodiments of the present application, there is provided an inter-module interface calling device, the device including:
the storage module is used for storing the first data flow information output by the first interface of the first functional module into the Redis database when the first functional module initiates a first interface call request to the second functional module;
the first calling module is used for calling the release mechanism of the Redis database and sending the first data stream information to a channel registered by the second functional module through a pre-packaged release interface;
the second calling module is used for calling the attribute table to perform data conversion on the first data stream information when the first thread initiated by the pre-packaged receiving interface in the second functional module monitors the first data stream information in the channel;
And the input module is used for inputting the first data flow information after the data conversion into the second interface of the second functional module.
In a third aspect of the embodiments of the present application, there is provided an apparatus comprising a memory, a processor and a computer program stored on the memory, wherein the processor executes the computer program to implement the method according to the first aspect.
In a fourth aspect of embodiments of the present application, there is provided a computer readable medium having stored thereon a computer program/instruction which, when executed by a processor, implements the method according to the first aspect.
The application has the following advantages and positive effects:
the embodiment of the application provides a method, a device, electronic equipment and a computer readable medium for calling interfaces among modules, wherein the method comprises the following steps: when a first function module initiates a first interface call request to a second function module, first data flow information output by the first interface of the first function module is stored in a Redis database, a release mechanism of the Redis database is called, the first data flow information is sent to a channel registered by the second function module through a pre-packaged release interface, and when a first thread initiated by the second function module at a pre-packaged receiving interface monitors the first data flow information in the channel, an attribute table is called to perform data conversion on the first data flow information, and the first data flow information after data conversion is input into a second interface of the second function module. The remote calling of interfaces among different modules can be realized based on a publish-subscribe mechanism of the Redis database.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application, illustrate and explain the application and are not to be construed as limiting the application.
In order to more clearly illustrate the technical solutions of the present application, the drawings that are needed in the description of the present application will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort to a person skilled in the art.
FIG. 1 is a flow chart of a method for calling interfaces between modules according to an embodiment of the present application;
FIG. 2 is a schematic structural diagram of each attribute table in a tree structure in an inter-module interface calling method according to an embodiment of the present application;
FIG. 3 is a flowchart of registering and monitoring a channel in a tree structure in an inter-module interface call method according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a call relationship in an inter-module interface call method according to an embodiment of the present application;
fig. 5 is a schematic diagram of a framework of an inter-module interface calling device according to an embodiment of the present application.
Detailed Description
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other.
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
Along with the increasing scale of the software system, the requirement of designing the whole software system into modularization is more and more obvious, through the modularized design, the hierarchy of the whole software system can be ensured to be clear, and each module can be divided into different work clearly, so that each team or person is responsible for the development work of a single module, the development efficiency of the software system is improved, and the effect of iterative development is achieved.
However, in the process of realizing modularization, data communication and function call between modules are particularly important, in the communication modes between the modules commonly used at present, communication modes of a system in the traditional sense such as a pipeline, a shared memory, signals and the like are adopted to realize communication between different modules, and the modes belong to the most traditional and mature stable communication modes, but each communication mode of the system in the traditional sense has own application scene and deficiency, such as the shared memory needs to process a mutual exclusion lock and needs to constantly poll for storing and acquiring related data in the mutual exclusion lock, so that the operation efficiency of a CPU is reduced, the pipeline can only realize unidirectional communication, and the traditional communication modes do not have the capability of interface remote call, namely the so-called interface remote call, namely the interface which can be presented or registered by the module B to the outside.
The remote calling mode of Dbus is adopted, although the mutual calling of interfaces between different modules can be realized, the remote calling mode provided by Dbus needs to specify corresponding interface calling and routing paths through relevant parameters such as service, path, interface and the like, only the most basic data types are allowed to be transmitted in the process of transmitting, the data types of each input parameter corresponding to the corresponding character expression are required to be relatively high in learning cost, the application scene is relatively complex, only the point-to-point communication mode, namely only the interface remote calling between two modules, can be realized, the situation that the same interface of a plurality of modules is called for a single module is seen, the calling can be only performed one by one based on the actual application scene, the application efficiency is low, the development of the modules is complicated, the interface calling or the referencing specified by the character strings is involved, the logic errors are caused when the improper processing is carried out, and the management of the character strings is not easy to manage and maintain like numerical value or macro definition after all.
Therefore, based on the problems and disadvantages of the current communication mode between modules in the aspect of remote interface call, the application provides an interface call method, device, electronic equipment and computer readable medium between modules, which can realize remote call of interfaces between different modules based on a release subscription mechanism of a Redis database.
Fig. 1 is a flowchart of an inter-module interface calling method according to an embodiment of the present application, as shown in fig. 1, where the inter-module interface calling method is provided in the embodiment. The method comprises the following steps:
in step S101, when a first functional module initiates a first interface call request to a second functional module, storing first data flow information output by a first interface of the first functional module into a Redis database;
in step S102, the publishing mechanism of the Redis database is called, and the first data stream information is sent to the channel registered by the second functional module through a pre-packaged publishing interface;
in step S103, when the first thread initiated by the pre-packaged receiving interface in the second functional module listens to the first data flow information in the channel, the attribute table is called to perform data conversion on the first data flow information;
in step S104, the data-converted first data stream information is input to the second interface of the second functional module.
First, in step S101, when a first function module initiates a first interface call request to a second function module, first data flow information output by a first interface of the first function module is stored in a Redis database. In this embodiment of the present application, the first functional module may be a functional module in a software system that has an interface call requirement, and the second functional module may be a functional module in the software system that can be called by an interface, where when the first functional module needs to call the interface of the second functional module, the first functional module sends a first interface call request, and the first interface of the first functional module outputs first data flow information that can be used as an input parameter when the interface is called, and stores the first data flow information in the Redis database.
The Redis database is a database based on memory and supporting distributed and sustainable key value pairs, has the advantages of high performance, strong expandability, high availability and the like, can support various data types, such as character string, list, set, ordered set, hash table hash and the like, and supports sorting in various different modes.
In the embodiment of the application, the message interception and message release of the corresponding channels are realized by providing the corresponding subscription (subscore) and release (publish) mechanisms through the Redis database, so that the remote call of the interfaces among different functional modules can be realized based on the release subscription mechanism of the Redis database.
Further, in step S102, the publishing mechanism of the Redis database is invoked, and the first data stream information is sent to the channel registered by the second functional module through a pre-packaged publishing interface. In this embodiment of the present application, the publishing interface is pre-packaged, and each functional module can call the publishing interface to send the data stream information to other functional modules, so after the first data stream information is stored in the Redis database through step S101, the publishing mechanism of the Redis database can be directly called, the first data stream information is sent to the publishing interface that is pre-packaged in a matching manner, and then the first data stream information is sent to the channel that is registered by the second functional module through the publishing interface.
Further, in step S103, when the first thread initiated by the pre-packaged receiving interface in the second functional module listens to the first data flow information in the channel, the attribute table is called to perform data conversion on the first data flow information. In this embodiment of the present invention, the receiving interface is also pre-packaged, where each functional module can call the receiving interface to receive the data stream information sent by another functional module, and the packaging interface can monitor the channel through the first thread initiated by the second functional module, and determine whether to monitor the first data stream information, and when the packaging interface receives the first data stream information sent by the first functional module through the first thread monitored channel initiated by the second functional module, the first data stream information is obtained, and because the parameter type of the first data stream information is the parameter type matched with the first interface outputting the first data stream information, when the other functional modules receive the first data stream information, the receiving interface needs to call the attribute table to perform data conversion on the first data stream information, where the data conversion includes conversion on the parameter type, the parameter number, the parameter length of the data, and so on.
Finally, in step S104, the data-converted first data stream information is input to the second interface of the second functional module. After the received first data stream information is subjected to data conversion in step S103, the first data stream information after the data conversion is input into the second interface of the second functional module, wherein parameters matched with the second interface of the second functional module are the first data stream information after the data conversion, so that the data distribution and the data receiving among different functional modules can be realized.
Through the above embodiment, when the first function module initiates a first interface call request to the second function module, the first data stream information output by the first interface of the first function module is stored in the Redis database, the issuing mechanism of the Redis database is called, the first data stream information is sent to the channel registered by the second function module through the pre-packaged issuing interface, and when the first thread initiated by the second function module by the pre-packaged receiving interface monitors the first data stream information in the channel, the attribute table is called to perform data conversion on the first data stream information, and the first data stream information after data conversion is input to the second interface of the second function module. The remote interface calling method can be realized based on a publish-subscribe mechanism of the Redis database, and can be realized by a memory-based Redis database.
Fig. 2 is a schematic structural diagram of each attribute table in a tree structure in an inter-module interface calling method according to an embodiment of the present application.
Optionally, the method further comprises:
constructing a tree structure;
obtaining module attributes, interface attributes and parameter attributes of each functional module, wherein the functional modules at least comprise the first functional module and the second functional module;
respectively constructing a corresponding attribute table based on the module attribute, the interface attribute and the parameter attribute, wherein the attribute table comprises a ModCode attribute description table, an IfcCode attribute description table and a parameter attribute description table;
and storing the attribute table correspondingly into the constructed tree structure.
Specifically, a tree structure is built in advance, the tree structure comprises a plurality of attribute tables, the attribute tables comprise a ModCode attribute description table, an IfcCode attribute description table and a parameter attribute description table, the tree structure is built based on module attributes, interface attributes and parameter attributes of each function module, and the function modules at least comprise a first function module and a second function module; when each function module is initialized, the module attribute, the interface attribute and the parameter attribute corresponding to the function module can be imported into the tree structure for storage, and when the function module changes, the module attribute, the interface attribute and the parameter attribute corresponding to the function module in the tree structure also change correspondingly.
Through the embodiment, the module attribute, the interface attribute and the parameter attribute of each functional module on the software system can be stored dynamically in the form of a tree structure, so that the remote calling of the interfaces among the modules can be realized conveniently.
Optionally, the ModCode attribute description table in the tree structure corresponds to the functional modules one by one, where the ModCode attribute description table includes a module code of the functional module, a first channel field, an ifcc code attribute description table pointer, and an ifcc code attribute description table number, where the ifcc code attribute description table pointer is used to point to the ifcc code attribute description table corresponding to the interface included in the functional module;
the ifcc node attribute description table corresponds to the interfaces contained in the functional module one by one, wherein the ifcc node attribute description table comprises an interface code of the interface, a second channel field, a parameter attribute description table pointer, a parameter number and an interface function pointer, the parameter attribute description table pointer is used for pointing to the parameter attribute description table of the interface corresponding to the ifcc node attribute description table, and the interface function pointer is used for pointing to a function of the interface;
The parameter attribute description table corresponds to the parameters of the interface, and is used for being called by a plurality of the ifcc code attribute description tables, wherein the parameter attribute description table comprises a parameter type, a parameter length and a default value, and the default value is used for representing the initial value of each parameter included in the parameter attribute description table before being modified.
Specifically, in the embodiment of the present application, a tree structure may be used to describe remote interface call attributes in the entire software system, where, as shown in fig. 2, the attribute table is divided into a ModCode attribute description table, an ifcc code attribute description table, and a parameter attribute description table, the tree structure includes a plurality of ModCode attribute description tables, a plurality of ifcc code attribute description tables, and a plurality of parameter attribute description tables, in fig. 2, modCode0, modCode1, and ModeCode2 may respectively correspond to one functional module, each functional module respectively corresponds to one ModCode attribute description table, each functional module includes a plurality of interfaces, ifcc code0, ifcc code1, and ifcc code2 respectively correspond to one interface, each interface corresponds to an IfcCode attribute description table, so each ModCode attribute description table can refer to a plurality of IfcCode attribute description tables in a tree structure, each interface matches a corresponding parameter attribute, paramTable represents a different parameter attribute table, so each IfcCode attribute description table refers to a parameter attribute table, and in addition, it should be noted that the parameter types possibly matched by different interfaces are the same, so the same parameter attribute table can correspond to a plurality of IfcCode attribute description tables, that is, a plurality of IfcCode attribute description tables can call the same parameter attribute table, correspond to the same parameter attribute table, and can be stored only once in the tree structure.
The contents contained in the ModCode attribute description table, the ifcc code attribute description table and the parameter attribute description table in the attribute table are specifically described below:
the ModCode attribute description table is shown in Table 1:
table 1: modCode attribute description table
The ModCode attribute description table comprises module codes of all the functional modules, a first channel field, an IfcCode attribute description table pointer and the number of IfcCode attribute description tables, wherein the IfcCode attribute description table pointer is used for pointing to an IfcCode attribute description table corresponding to an interface contained under the functional modules.
The module code can be used as a unique identifier of the functional module, and the module code is a numerical value of 0-255, so that 255 functional modules, such as the functional modules, can be identified at maximum: PSU, which can be identified by 0, functional module: the CPLD may be identified by 1, where the first channel field is used to describe the 0 th field in the channel corresponding fields of the functional modules monitored by the receiving interface in the Redis database, and may be a string, and when the CPLD is finally monitored, the CPLD is used as the 0 th field of the monitored channel, for example: PSU, ifcCode table pointer is used to point to the IfcCode attribute description tables of all interfaces under the functional module, and is a pointer type, and can be traversed to all IfcCode attribute description tables under the corresponding functional module through this traversal, for example: PSUIfcTable, ifcCode the attribute description table number is used to identify how many corresponding interfaces the functional module shares, and may be in the form of a numerical value, such as: sizeof (PSUIfcTable)/sizeof (IFC_PROPERTY_TBL).
The IfcCode attribute description table is shown in table 2:
table 2: ifccode attribute description table
The IfcCode attribute description table corresponds to interfaces contained in the functional module one by one, the IfcCode attribute description table comprises interface codes of all interfaces, a second channel field, parameter attribute description table pointers, parameter numbers and interface function pointers, the parameter attribute description table pointers are used for pointing to the parameter attribute description tables of the interfaces corresponding to the IfcCode attribute description table, and the interface function pointers are used for pointing to functions of the interfaces. The interface code is used for identifying a unique identifier of a certain interface in the functional module, and is a numerical value of 0-255, and 255 interfaces in a single module can be identified at maximum, taking the PSU functional module as an example, the interface code can be GetPSUInfo, setPSUMode, the second channel field is used for describing in the Redis database, and the 1 st field in the channel corresponding field of the functional module monitored by the receiving interface: as a string, the 1 st field of the channel as a snoop when the final snoop is made, such as:
"GetPSUInfo", "SetPSUMode"; the parameter attribute description table pointer is used for pointing to the parameter attribute description table of a certain interface below the functional module, and is a pointer type, and can traverse the relevant attribute of all parameters of the corresponding interface through the pointer type, such as: getPSUInfoParamTable, setPSUModeParamTable; the number of parameters is used to identify the number of parameters of the interface, which is a numerical value, and identify how many parameters of the interface exist in total, such as: sizeof (GetPSUInfoParamTable)/sizeof (Param TBL); the interface function pointer represents a pointer to a function of the interface, through which a corresponding function interface can be accessed, such as: getPSUInfoParam.
The parameter attribute description table is shown in table 3:
table 3: parameter attribute description table
The parameter attribute description table is used for being called by a plurality of IfcCode attribute description tables, wherein the parameter attribute description table comprises a parameter type, a parameter length and a default value, and the default value is used for representing the initial value of each parameter included in the parameter attribute description table before being modified.
Wherein the parameter type indicates the type of parameter, such as: int32, uint32, uint16, bool, etc.; the parameter length is a numerical type, such as: 2,3; the default value indicates an initial value when the parameter is not available, for example, when a parameter is not assigned or modified, the initial value is used as the value of the parameter.
Through the embodiment, the module attribute description, the interface attribute description and the parameter attribute description of each functional module can be stored in the form of a tree structure, so that the attribute description stored in the tree structure can be directly called when a remote interface between the modules is called.
Optionally, the step S103 includes:
invoking the attribute table to acquire a first interface attribute of the first interface and a second interface attribute of the second interface, acquiring a first data attribute description based on the first interface attribute, and acquiring a second data attribute description based on the second interface attribute;
Analyzing the first data stream information according to the first data attribute description;
and carrying out data conversion on the parsed first data stream information according to the second data attribute description.
Specifically, in step S103, the attribute table is called to perform data conversion on the first data stream information, which is obtained by calling each attribute table in the tree structure to obtain a first interface attribute of the first interface and a second interface attribute of the second interface, where the first interface attribute is obtained by calling the first interface attribute description table associated with the first interface, the second interface attribute is obtained by calling the second interface attribute description table associated with the second interface, the first data attribute description is obtained by calling the parameter attribute description table pointed by the parameter attribute description table pointer in the first interface attribute description table associated with the first interface, the second data attribute description is obtained by calling the parameter attribute description table pointed by the parameter attribute description table pointer in the second interface, and further, the first data stream information is parsed according to the information such as the parameter type, the parameter number, the parameter length and the like in the first data attribute description, and after the first data stream information is parsed, the first data stream information is further parsed according to the parameter type, the parameter length and the parameter information contained in the second data stream description.
Through the embodiment, after the receiving interface monitors that the first data stream information is received in the channel corresponding to the second functional module, each attribute table in the pre-stored tree structure can be called to convert the first data stream information into the data stream information which can be received by the second interface of the second functional module, so that the situation that a plurality of sets of character string data are required to be maintained in a remote calling process is avoided, the problem that the character strings are difficult to manage and maintain is avoided, programming is easy, and development efficiency is improved.
Optionally, after the first data flow information after the data conversion is input to the second interface of the second functional module, the method further includes:
processing the first data stream information after data conversion through the second functional module to obtain second data stream information, and storing the second data stream information into a Redis database;
performing data conversion on the second data stream information according to the first data attribute description;
and calling a release mechanism of the Redis database, and sending the second data flow information after the data conversion to the first functional module through the release interface.
Specifically, after receiving the first data stream information after data conversion, the second functional module can directly call the interface function pointer of the second interface, process and operate the first data stream information after data conversion through the corresponding interface function, output the second data stream information, store the second data stream information into the Redis database, further call the issuing mechanism of the Redis database, and send the second data stream information after data conversion to the first functional module through the issuing interface.
It should be noted that, the publishing interface and the receiving interface are both pre-packaged interfaces, and each functional module can directly and simultaneously call the publishing interface or the receiving interface to realize the sending and receiving of the data stream, and the publishing interface and the receiving interface are both connected with the Redis database and the tree structure storing the attribute table, so that the publishing and subscribing mechanism and the corresponding attribute table can be conveniently called.
Through the embodiment, the second functional module can call the issuing mechanism of the Redis database, and the second data flow information after data conversion is sent to the first functional module through the issuing interface, so that the remote call of the interface is realized.
Fig. 3 is a flowchart of registering and monitoring a channel in a tree structure in an inter-module interface calling method according to an embodiment of the present application.
Optionally, after the storing the attribute table in the constructed tree structure, the method further includes:
acquiring a first channel field in the module attribute and a second channel field of the interface attribute, and splicing the first channel field and the second channel field to obtain channels registered by the functional modules;
in each functional module, an initiating thread monitors a channel registered by the functional module.
Specifically, different channels are used to implement different services in the software system, so each functional module performs channel registration during initialization, as shown in fig. 3, when a channel of a certain functional module is registered, a ModCode attribute description table of a corresponding functional module is searched, the corresponding IfcCode attribute description table is further traversed, a first channel field in a module attribute and a second channel field of an interface attribute are spliced, a channel registered by each functional module is obtained, after the channel registration is completed, a corresponding thread is initiated in the corresponding functional module, and the channel is monitored through the thread.
By the embodiment, the independent monitoring channels can be obtained by splicing the first channel field and the second channel field of the functional module in the constructed tree structure, and the corresponding threads are initiated to monitor, so that the monitoring of the channels of each functional module is realized.
Optionally, the method further comprises:
when a first function module initiates a first interface call request to a second function module, the receiving interface initiates a second thread in the second function module;
the second thread is used for processing interface calling requests of other functional modules to the second functional module.
Specifically, in this embodiment, when multiple functional modules call the same interface of the same functional module, a call process of the interface needs to be implemented according to the sequence of call period requests, so, in order to further improve call efficiency of the interface, when each time an interface call request of a certain interface is received, a new thread is built in the functional module where the interface is located, for example, when a first functional module initiates a call request to a first interface of a second functional module, a second thread is built in the second functional module where the interface is located, so that the call request of the interface of other functional modules can be processed through the newly built second thread.
By the above embodiment, when a plurality of functional modules call the same interface of the same functional module, the interface call can be realized without waiting for the execution of the previous call request, but the interface call requests of the plurality of functional modules can be synchronously performed.
Fig. 4 is a schematic diagram of call relationships in an inter-module interface call method according to an embodiment of the present application, as shown in fig. 4.
In this embodiment of the present application, each function module is adapted to a call relationship shown in fig. 4, where each function module performs initialization of the function module through an initialization module, including importing a module attribute, an interface attribute, and a parameter attribute of the function module into a tree structure, registering a corresponding channel, and initiating a corresponding thread to monitor the channel, implementing release and reception of first data stream information through a release interface and a receiving interface, when the first function module releases the first data stream information, storing the first data stream information into a dis database, and calling a release mechanism to send the first data stream information to a release interface, the release interface sends the first data stream information to a channel of the function module corresponding to the called interface, the receiving interface listens to the channel, when the first data stream information is monitored, invoking an attribute table of the tree structure to parse and convert data stream information, inputting the converted first data stream information into the call interface, implementing release and operation of the first data stream information by an interface function of the call interface, and outputting a second data stream information to a second data stream, and sending the second data stream information to the second call interface, and implementing release of the second data stream information by the second call interface.
Fig. 5 is a schematic frame diagram of an inter-module interface calling device according to an embodiment of the present application, and as shown in fig. 5, an embodiment of the present application provides an inter-module interface calling device, where the device includes:
the storage module 11 is configured to store, when a first functional module initiates a first interface call request to a second functional module, first data flow information output by a first interface of the first functional module into a dis database;
the first calling module 12 is configured to call a release mechanism of the Redis database, and send the first data flow information to a channel registered by the second functional module through a pre-packaged release interface;
the second calling module 13 is configured to call an attribute table to perform data conversion on the first data stream information when the first thread initiated by the pre-packaged receiving interface in the second functional module listens to the first data stream information in the channel;
and the input module 14 is used for inputting the first data flow information after the data conversion into the second interface of the second functional module.
Optionally, the second calling module 13 includes:
an attribute description acquiring unit, configured to invoke the attribute table to acquire a first interface attribute of the first interface and a second interface attribute of the second interface, acquire a first data attribute description based on the first interface attribute, and acquire a second data attribute description based on the second interface attribute;
The analysis unit is used for analyzing the first data stream information according to the first data attribute description;
and the first data conversion unit is used for carrying out data conversion on the parsed first data stream information according to the second data attribute description.
Optionally, the apparatus further comprises:
the processing unit is used for processing the first data stream information after the data conversion through the second functional module after the first data stream information after the data conversion is input to the second interface of the second functional module, obtaining second data stream information and storing the second data stream information into a Redis database;
the second data conversion unit is used for carrying out data conversion on the second data stream information according to the first data attribute description;
and the sending unit is used for calling the issuing mechanism of the Redis database and sending the second data flow information after the data conversion to the first functional module through the issuing interface.
Optionally, the apparatus further comprises:
a building unit for building a tree structure;
the device comprises an acquisition unit, a control unit and a control unit, wherein the acquisition unit is used for acquiring module attributes, interface attributes and parameter attributes of each functional module, and the functional modules at least comprise a first functional module and a second functional module;
Respectively constructing a corresponding attribute table based on the module attribute, the interface attribute and the parameter attribute, wherein the attribute table comprises a ModCode attribute description table, an IfcCode attribute description table and a parameter attribute description table;
and the storage unit is used for correspondingly storing the attribute table into the constructed tree structure.
Optionally, the apparatus further comprises:
a channel registration unit, configured to obtain a first channel field in the module attribute and a second channel field of the interface attribute after the attribute table is stored in the constructed tree structure, and splice the first channel field and the second channel field to obtain channels registered by each functional module;
and the monitoring unit is used for monitoring the channel registered by the functional module by the initiating thread in each functional module.
Optionally, the apparatus further comprises:
and the thread initiating unit is used for initiating a second thread in the second functional module by the receiving interface when the first functional module initiates a first interface call request to the second functional module.
Another embodiment of the present application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory, where the processor executes the computer program to implement the method according to any one of the embodiments.
Another embodiment of the present application also provides a computer readable medium having a computer program stored thereon, wherein the program when executed by a processor implements a method as described in any of the above embodiments.
For the device, since it is substantially similar to the method embodiment, the description is relatively simple, and reference is made to the description of the method embodiment for relevant points.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present application may be provided as a method, apparatus, or computer program product. Accordingly, the present embodiments may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the application. 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 terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, 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.
While preferred embodiments of the present embodiments have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the present application.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal 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 terminal. 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 terminal device comprising the element.
The foregoing has described in detail the method, apparatus, electronic device and computer readable medium for invoking interfaces between modules provided in the present application, and specific examples have been applied to illustrate the principles and embodiments of the present application, where the above description of the embodiments is only for helping to understand the method and core idea of the present application; meanwhile, as those skilled in the art will vary in the specific embodiments and application scope according to the ideas of the present application, the contents of the present specification should not be construed as limiting the present application in summary.

Claims (10)

1. An inter-module interface calling method, the method comprising:
when a first function module initiates a first interface call request to a second function module, storing first data flow information output by a first interface of the first function module into a Redis database;
invoking a release mechanism of the Redis database, and sending the first data stream information to a channel registered by the second functional module through a pre-packaged release interface;
when a first thread initiated by a pre-packaged receiving interface in a second functional module monitors first data flow information in the channel, calling an attribute table to perform data conversion on the first data flow information;
And inputting the first data stream information after the data conversion into a second interface of the second functional module.
2. The method for calling an interface between modules according to claim 1, wherein when the prepackaged receiving interface monitors the first data stream information in the channel at the first thread initiated by the second functional module, calling an attribute table to perform data conversion on the first data stream information, includes:
invoking the attribute table to acquire a first interface attribute of the first interface and a second interface attribute of the second interface, acquiring a first data attribute description based on the first interface attribute, and acquiring a second data attribute description based on the second interface attribute;
analyzing the first data stream information according to the first data attribute description;
and carrying out data conversion on the parsed first data stream information according to the second data attribute description.
3. The method according to claim 2, further comprising, after the first data flow information after the data conversion is input to the second interface of the second functional module:
Processing the first data stream information after data conversion through the second functional module to obtain second data stream information, and storing the second data stream information into a Redis database;
performing data conversion on the second data stream information according to the first data attribute description;
and calling a release mechanism of the Redis database, and sending the second data flow information after the data conversion to the first functional module through the release interface.
4. The inter-module interface calling method of claim 1, wherein the method further comprises:
constructing a tree structure;
obtaining module attributes, interface attributes and parameter attributes of each functional module, wherein the functional modules at least comprise the first functional module and the second functional module;
respectively constructing a corresponding attribute table based on the module attribute, the interface attribute and the parameter attribute, wherein the attribute table comprises a ModCode attribute description table, an IfcCode attribute description table and a parameter attribute description table;
and storing the attribute table correspondingly into the constructed tree structure.
5. The method according to claim 4, wherein a ModCode attribute description table in the tree structure corresponds to the function modules one by one, wherein the ModCode attribute description table includes a module code of the function module, a first channel field, an ifcc code attribute description table pointer, and an ifcc code attribute description table number, and the ifcc code attribute description table pointer is used for pointing to the ifcc code attribute description table corresponding to the interface included in the function module;
The ifcc node attribute description table corresponds to the interfaces contained in the functional module one by one, wherein the ifcc node attribute description table comprises an interface code of the interface, a second channel field, a parameter attribute description table pointer, a parameter number and an interface function pointer, the parameter attribute description table pointer is used for pointing to the parameter attribute description table of the interface corresponding to the ifcc node attribute description table, and the interface function pointer is used for pointing to a function of the interface;
the parameter attribute description table corresponds to the parameters of the interface, and is used for being called by a plurality of the ifcc code attribute description tables, wherein the parameter attribute description table comprises a parameter type, a parameter length and a default value, and the default value is used for representing the initial value of each parameter included in the parameter attribute description table before being modified.
6. The method for calling interfaces between modules according to claim 4, further comprising, after said storing said attribute table in said built tree structure, the steps of:
acquiring a first channel field in the module attribute and a second channel field of the interface attribute, and splicing the first channel field and the second channel field to obtain channels registered by the functional modules;
In each functional module, an initiating thread monitors a channel registered by the functional module.
7. The inter-module interface calling method of claim 1, wherein the method further comprises:
when a first function module initiates a first interface call request to a second function module, the receiving interface initiates a second thread in the second function module;
the second thread is used for processing interface calling requests of other functional modules to the second functional module.
8. An inter-module interface calling device, the device comprising:
the storage module is used for storing the first data flow information output by the first interface of the first functional module into the Redis database when the first functional module initiates a first interface call request to the second functional module;
the first calling module is used for calling the release mechanism of the Redis database and sending the first data stream information to a channel registered by the second functional module through a pre-packaged release interface;
the second calling module is used for calling the attribute table to perform data conversion on the first data stream information when the first thread initiated by the pre-packaged receiving interface in the second functional module monitors the first data stream information in the channel;
And the input module is used for inputting the first data flow information after the data conversion into the second interface of the second functional module.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory, wherein the processor executes the computer program to implement the inter-module interface calling method of any of claims 1-7.
10. A computer readable medium, having stored thereon a computer program/instruction which, when executed by a processor, implements the inter-module interface invoking method according to any of claims 1-7.
CN202311482005.8A 2023-11-08 2023-11-08 Inter-module interface calling method, device, equipment and readable medium Pending CN117648356A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311482005.8A CN117648356A (en) 2023-11-08 2023-11-08 Inter-module interface calling method, device, equipment and readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311482005.8A CN117648356A (en) 2023-11-08 2023-11-08 Inter-module interface calling method, device, equipment and readable medium

Publications (1)

Publication Number Publication Date
CN117648356A true CN117648356A (en) 2024-03-05

Family

ID=90044227

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311482005.8A Pending CN117648356A (en) 2023-11-08 2023-11-08 Inter-module interface calling method, device, equipment and readable medium

Country Status (1)

Country Link
CN (1) CN117648356A (en)

Similar Documents

Publication Publication Date Title
CN110297620B (en) Dynamic rule maintenance and generation method based on Drools
CN108696381B (en) Protocol configuration method and device
CN110502212B (en) Multi-language-oriented high concurrency online development supporting method
CN101405761B (en) For service reception and the method and system processing data
CN110119292A (en) System operational parameters querying method, matching process, device and node device
US8707329B2 (en) Open framework system for heterogeneous computing and service integration
CN101968793A (en) Method and system for checking on basis of disparate data source data
CN112905323B (en) Data processing method, device, electronic equipment and storage medium
US20220014584A1 (en) Distributed pipeline configuration in a distributed computing system
CN115016784B (en) Low code application multiplexing method, application analysis system, equipment and storage medium
US20080098346A1 (en) Mapping Web Services Description Language documents to XQuery functions
Prinz et al. A novel I4. 0-enabled engineering method and its evaluation
CN114090388A (en) Information acquisition method, server cluster, server and equipment
CN102316128A (en) A kind ofly be used to generate network service method and device
CN113760987A (en) Data processing method and data processing platform
CN110941655A (en) Data format conversion method and device
CN117648356A (en) Inter-module interface calling method, device, equipment and readable medium
CN113094561B (en) Webpage generating method, webpage generating device, electronic equipment and storage medium
CN114817389A (en) Data processing method, data processing device, storage medium and electronic equipment
CN109117152B (en) Service generation system and method
CN115034175A (en) Table data processing method, device, terminal and storage medium
CN112416980A (en) Data service processing method, device and equipment
Hirmer Model based approaches to the internet of things
WO2014176954A1 (en) Processing method, device and system for data of distributed storage system
CN113486024B (en) Data dictionary information transmission method and device, storage medium and electronic equipment

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