Method and device for generating programming language library, electronic equipment and storage medium

By receiving file conversion requests and using a pre-configured protocol generator to generate protocol files for the second type of remote procedure call library, the problem of low efficiency in manually writing protocol definition files is solved, and rapid automated migration and efficient file processing are achieved.

CN114780073BActive Publication Date: 2026-02-03BEIJING EVERNOTE TECH CO LTD +2
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210435698.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-24
Publication Date
2026-02-03
Estimated Expiration
2042-04-24

AI Technical Summary

Technical Problem

In existing technologies, manually writing protocol definition files to achieve remote procedure call library migration is inefficient and time-consuming.

Method used

By receiving file conversion requests, a pre-configured protocol generator is used to generate protocol files for the second type of remote procedure call library, automating the migration process and generating programming language class libraries.

Benefits of technology

It improves the speed and efficiency of file data retrieval and processing, reduces the time spent manually writing protocol definition files, and enables rapid automated migration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114780073B_ABST
    Figure CN114780073B_ABST
Patent Text Reader

Abstract

The application discloses a programming language library generation method and device, electronic equipment and a storage medium. The generation method comprises the following steps: receiving a file conversion request, wherein the file conversion request carries file information of a first remote procedure call library and a remote procedure call command; generating a protocol file of a second remote procedure call library based on the file information by using a pre-configured protocol generator; executing the remote procedure call command, calling the protocol file of the second remote procedure call library, and generating a programming language library. The application solves the technical problem of low efficiency in the prior art that a protocol definition file is manually written to call file data.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of information processing, in particular to a programming language library generation method and device, electronic equipment and storage medium. BACKGROUND

[0002] In related technologies, for remote procedure call libraries developed by different applications or manufacturers, if files or data of the remote procedure call libraries need to be migrated to each other (for example, if the need to migrate Thrift to gRPC or use gRPC service to proxy Thrift is encountered), the current means is to manually write a protocol file according to the protocol definition file of the call library to be migrated, and at the same time, the interface served by the file also needs to manually implement the strategy of the call library to be migrated. This way of manually implementing file definition and file calling by programmers is low in efficiency and time-consuming.

[0003] At present, no effective solution has been proposed for the above problems. SUMMARY

[0004] The embodiments of the present application provide a programming language library generation method and device, electronic equipment and storage medium, to at least solve the technical problem of low efficiency in related technologies that use a manual method to write a protocol definition file to call file data.

[0005] According to an aspect of an embodiment of the present application, a programming language library generation method is provided, including: receiving a file conversion request, wherein the file conversion request carries file information and a remote procedure call command of a first type of remote procedure call library; generating a protocol file of a second type of remote procedure call library based on the file information using a pre-configured protocol generator; executing the remote procedure call command to call the protocol file of the second type of remote procedure call library, and generating a programming language library.

[0006] Optionally, after receiving the file conversion request, the method further includes: obtaining service interface information, structure information and file basic information about the first type of remote procedure call library; putting the service interface information, the structure information and the file basic information into a cache; putting all dependent information structures in the service interface information, the structure information and the file basic information in the cache into a newly created file to remove circular dependencies; and summarizing the service interface information, the structure information and the file basic information from which the circular dependencies are removed into the file information.

[0007] Optionally, the file base information comprises at least one of the following: a file version identifier, a referenced file, and a file package name; the service interface information comprises at least one of the following: a service name, all interface names, parameters, return values, and a request path; and the structure body information comprises at least one of the following: a structure name, a structure attribute name, and a structure type.

[0008] Optionally, the step of generating, by the pre-configured protocol generator, the protocol file of the second type of remote procedure call library based on the file information comprises the following steps: the pre-configured protocol generator is used to splice the service interface information, the structure body information, and the file base information respectively to generate the protocol file of the second type of remote procedure call library.

[0009] Optionally, the method for generating a programming language class library is applied to a call library converter.

[0010] Optionally, when the call library converter is constructed, the following steps are included: an information object of a target programming language class is created; a class name and a package name of a file package are recorded in the information object; dependency references, field information, and conversion strategies are recorded in the information object, wherein the field information comprises at least one of the following: a type and a name, and the conversion strategies comprise at least one of the following: a strategy name, return values, and parameters; and the package name, the dependency references, the class name, all field information, and all conversion strategies are spliced in sequence according to a specified format of the target programming language class.

[0011] Optionally, the first type of remote procedure call library is a gRPC call library, and the second type of remote procedure call library is a Thrift call library; or the first type of remote procedure call library is a Thrift call library, and the second type of remote procedure call library is a gRPC call library.

[0012] According to another aspect of the embodiment of the present application, a method for generating a programming language class library is provided, which comprises the following steps: receiving a file conversion request, wherein the file conversion request carries file information of a first type of remote procedure call library and a remote procedure call command; generating, by a pre-configured protocol generator, a protocol file of a second type of remote procedure call library based on the file information; and executing the remote procedure call command to call the protocol file of the second type of remote procedure call library to generate a programming language class library.

[0013] Optionally, the generation apparatus of the programming language class library further comprises: a first acquisition module, configured to acquire service interface information, structure information and file basis information about the first type of remote procedure call library after receiving the file conversion request; a putting module, configured to put the service interface information, the structure information and the file basis information into a cache; a removing module, configured to remove all dependent information structures in the service interface information, the structure information and the file basis information in the cache from a newly created file to remove circular dependency; and an induction module, configured to induce the service interface information, the structure information and the file basis information after removing the circular dependency into the file information.

[0014] Optionally, the file basis information comprises at least one of the following: a file version identifier, a referenced file and a file package name; the service interface information comprises at least one of the following: a service name, all interface names, parameters, return values and request paths; and the structure information comprises at least one of the following: a structure name, a structure attribute name and a structure type.

[0015] Optionally, the generation unit comprises a splicing module, configured to use a pre-configured protocol generator to splice the service interface information, the structure information and the file basis information respectively to generate a protocol file of the second type of remote procedure call library.

[0016] Optionally, the generation method of the programming language class library is applied to a call library converter.

[0017] Optionally, when constructing the call library converter, the following steps are included: creating an information object of a target programming language class; recording a class name and a package name of a file package into the information object; and recording dependent references, field information and conversion strategies into the information object, wherein the field information comprises at least one of the following: a type and a name, and the conversion strategies comprise at least one of the following: a strategy name, return values and parameters; and the package name, the dependent references, the class name, all field information and all conversion strategies are spliced in sequence according to a specified format of the target programming language class.

[0018] Optionally, the first type of remote procedure call library is a gRPC call library, and the second type of remote procedure call library is a Thrift call library; or the first type of remote procedure call library is a Thrift call library, and the second type of remote procedure call library is a gRPC call library.

[0019] According to another aspect of the embodiment of the present application, an electronic device is further provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the generation method of the programming language class library according to any one of the above aspects by executing the executable instructions.

[0020] According to another aspect of the embodiments of the present application, there is also provided a computer readable storage medium comprising a stored computer program, wherein the computer readable storage medium, when the computer program is run, controls a device where the computer readable storage medium is located to perform the method for generating a programming language library according to any one of the above.

[0021] In the embodiments of the present application, a file conversion request is received, wherein the file conversion request carries file information and a remote procedure call command of a first type of remote procedure call library; a pre-configured protocol generator is used to generate a protocol file of a second type of remote procedure call library based on the file information; and the remote procedure call command is executed to call the protocol file of the second type of remote procedure call library to generate a programming language library. In the embodiments, when a migration request (or a conversion request, a calling request, etc.) between calling libraries is received, a protocol file of a second type of remote procedure call library can be generated based on file information by using a pre-configured protocol generator. The protocol generator can avoid a large number of protocol definition migration and implementation processes, can quickly and automatically implement a migration protocol file, can improve the calling speed of file data, and can improve the file processing efficiency, thereby solving the technical problem of low efficiency in the related art that a protocol definition file is manually written to call file data. BRIEF DESCRIPTION OF DRAWINGS

[0022] The accompanying drawings, which are included to provide a further understanding of the present application and are incorporated in and constitute a part of this application, illustrate embodiments of the present application and together with the description serve to explain the present application. In the drawings:

[0023] Figure 1 FIG. 1 is a flowchart of a method for generating a programming language library according to an embodiment of the present application;

[0024] Figure 2 FIG. 3 is a schematic diagram of calling an open source remote procedure call library according to an embodiment of the present application;

[0025] Figure 3 FIG. 4 is a schematic diagram of a device for generating a programming language library according to an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to enable persons skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings of the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by persons skilled in the art without creative labor should fall within the scope of protection of the present application.

[0027] It is to be understood that the terminology "first", "second", and the like used in the specification and the claims of the application as well as the foregoing drawings is merely intended to distinguish between similar objects and not necessarily for describing a special order or sequence. It is to be understood that data so used can be interchanged, where appropriate, so that the embodiments of the application described herein can be carried out in other than the order shown or described herein. Furthermore, the terms "comprise" and "comprising" and any variations thereof are intended to cover a non-exclusive inclusion, for example, a process, method, system, product or apparatus that comprises a list of steps or units can not necessarily be limited to those steps or units that are clearly recited, but can include other not expressly recited steps or units, without departing from the scope of the process, method, product or apparatus uniquely characterized.

[0028] To facilitate the understanding of the application by those skilled in the art, some terms or nouns involved in the embodiments of the application are explained as follows:

[0029] gRPC, gRPC Remote Procedure Calls, is an open source remote procedure call system initiated by Google Company, which can be transmitted based on HTTP protocol.

[0030] Thrift: an open source remote procedure call library.

[0031] The application can be applied to various file migration systems or file transmission systems. Taking the call between gRPC and Thrift as an example, the service interface information, structure body information and enumeration information can be analyzed by a file collector and put into a cache according to a Thrift generation class; then the various information in the cache can be removed from the circular dependency by a circular dependency resolver, which is to put all dependencies into a new file; finally, a gRPC protocol file can be generated by a protocol generator. Or the corresponding converter (Java) can be generated by the Thrift generation class to convert the Thrift data into the corresponding gRPC data. The application will be described in detail in combination with the embodiments.

[0032] Embodiment one

[0033] According to the embodiments of the application, a programming language library generation method is provided. It should be noted that the steps shown in the flowchart of the drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described herein can be executed in a different order from that shown herein.

[0034] Figure 1 is a flowchart of an optional programming language library generation method according to the embodiments of the application, as shown inFigure 1 As shown, the method comprises the following steps:

[0035] In step S102, a file conversion request is received, wherein the file conversion request carries file information and a remote procedure call command of a first type of remote procedure call library.

[0036] In step S104, a pre-configured protocol generator is used to generate a protocol file of a second type of remote procedure call library based on the file information.

[0037] In step S106, the remote procedure call command is executed to call the protocol file of the second type of remote procedure call library to generate a programming language class library.

[0038] Through the above steps, the file conversion request can be received, wherein the file conversion request carries the file information and the remote procedure call command of the first type of remote procedure call library. The pre-configured protocol generator is used to generate the protocol file of the second type of remote procedure call library based on the file information. The remote procedure call command is executed to call the protocol file of the second type of remote procedure call library to generate the programming language class library. In this embodiment, when a migration request (or a conversion request, a call request, etc.) between calling libraries is received, the pre-configured protocol generator can be used to generate the protocol file of the second type of remote procedure call library based on the file information. The protocol generator can eliminate a large number of protocol definition migration and implementation processes, can quickly and automatically implement the migration protocol file, can improve the calling speed of file data, and can improve the file processing efficiency, thereby solving the technical problem of low efficiency in the related art in which a protocol definition file is manually written to call file data.

[0039] As an optional implementation manner of this embodiment, the first type of remote procedure call library is a gRPC calling library, and the second type of remote procedure call library is a Thrift calling library. Alternatively, the first type of remote procedure call library is a Thrift calling library, and the second type of remote procedure call library is a gRPC calling library.

[0040] The programming language class library generation method provided in this embodiment can be applied to a calling library converter.

[0041] Before the calling library converter is used, the calling library converter needs to be constructed. Optionally, when the calling library converter is constructed, the following steps are included: an information object of a target programming language class is created; a class name and a package name of a file package are recorded in the information object; a dependency reference, field information, and a conversion strategy are recorded in the information object, wherein the field information includes at least one of the following: a type and a name, and the conversion strategy includes at least one of the following: a strategy name, a return value, and a parameter; and the package name, the dependency reference, the class name, all the field information, and all the conversion strategies are sequentially spliced according to a specified format of the target programming language class.

[0042] The target programming language in the embodiment can be selected as Java, and a calling between Thrift / gRPC is taken as an example to illustrate an implementation of creating a Thrift / gRPC converter, including splicing a string of a java file and then outputting the string to the java file. The splicing process includes: 1. creating a Java class information object; 2. recording a class name and a package name into the Java class information object; 3. recording a dependency reference, a field and a method into the Java class information object; and 4. splicing a package name, a dependency reference, a class name, all fields (types and names) and all methods / policies (policy method names, return values, parameters and method contents) in sequence according to a format of the java file.

[0043] The above implementation steps are schematically illustrated below in combination with the already constructed calling library converter and the pre-constructed protocol generator.

[0044] In step S102, a file conversion request is received, wherein the file conversion request carries file information of a first type of remote procedure calling library and a remote procedure calling command.

[0045] The file conversion request can be sent by a client, and the file conversion request can include authentication information, a message header, data content and the like. Through the file conversion request, protocol files of different types of remote procedure calling libraries can be converted into each other.

[0046] Optionally, after receiving the file conversion request, the method further includes: obtaining service interface information, structure body information and file basic information about the first type of remote procedure calling library; putting the service interface information, the structure body information and the file basic information into a cache; putting all dependent information structures in the service interface information, the structure body information and the file basic information in a newly created file to remove a circular dependency; and summarizing the service interface information, the structure body information and the file basic information after removing the circular dependency as file information.

[0047] In the embodiment of the application, the service interface information, the structure body information and the enumeration information can be generated according to a Thrift generated class, loaded and analyzed by a file collector and put into a cache; and then various information in the cache can be removed from a circular dependency by a circular dependency resolver, and the mode is to put all dependencies into a new file.

[0048] Optionally, the file basic information includes at least one of the following: a file version identifier, a reference file and a file package name; the service interface information includes at least one of the following: a service name, all interface names, parameters, return values and a request path; and the structure body information includes at least one of the following: a structure name, a structure attribute name and a structure type.

[0049] In step S104, a pre-configured protocol generator is used to generate a protocol file of the second type of remote procedure call library based on the file information.

[0050] The protocol generator of the embodiment is pre-configured. When configuring the protocol generator (taking the Grpc protocol generator as an example for illustrative description), the following steps are included: splicing the string of the proto file, and then outputting the string to the proto file. The splicing process includes the following steps: 1. splicing the version number, the reference file, the package name and other file basic information; 2. splicing the service interface information: the service name, all interface names, parameters, return values and request paths; 3. splicing all structure information: the structure name, all attributes (attribute name and type) in the structure.

[0051] Optionally, the step of generating the protocol file of the second type of remote procedure call library based on the file information by using the pre-configured protocol generator includes the following steps: splicing the service interface information, the structure body information and the file basic information respectively by using the pre-configured protocol generator, and generating the protocol file of the second type of remote procedure call library.

[0052] In step S106, a remote procedure call command is executed to call the protocol file of the second type of remote procedure call library, and a programming language class library is generated.

[0053] For example, the gRPC protocol file is generated by the protocol generator, and then the generation command of gRPC can be executed to generate the Java class library.

[0054] The embodiment can generate the gRPC protocol file according to the Thrift generation class, load and analyze the service interface information, the structure body information and the enumeration information through the file collector, and put them into the cache; then the loop dependency resolver is used to remove the loop dependency of various information in the cache, and the mode is to put all dependencies into a new file; finally, the protocol generator is used to generate the gRPC protocol file.

[0055] The embodiment can generate the corresponding converter (Java) according to the Thrift generation class, and can convert the Thrift data into the corresponding gRPC data. When the demand of migrating Thrift to gRPC or using gRPC to proxy Thrift is encountered, the embodiment does not need a programmer to manually write a gRPC protocol file according to the Thrift protocol definition file again, and the embodiment can save a lot of protocol definition migration and implementation process, and quickly realize the migration of file data.

[0056] The embodiments of the present application will be described in detail below with reference to the specific implementation modes.

[0057] Figure 2 is a schematic diagram of calling an open source remote procedure call library according to an embodiment of the present application. Figure 2As shown, its leftmost side includes two types of generator classes: thrift generator class and gRPC generator class.

[0058] Firstly, the Thrift generated class in the first column is used by the file collector in the second column to load and analyze the service interface information (i.e., Figure 2 The service in the middle), structure information (i.e. Figure 2 The structure in the text) and enumeration information (i.e. Figure 2 The enumerations in the file are then placed into the file information cache, and this information is reflected in... Figure 2 The third column in the table.

[0059] Point 2, through Figure 2 The second column's circular dependency resolver removes circular dependencies from the cached information (specifically, it reassigns all dependency structures to new files).

[0060] Point 3, through Figure 2 The protocol generator in the second column ( Figure 2 This demonstrates how a gRPC protocol generator generates gRPC protocol files. Figure 2 The first column contains the GRPC protocol, and then the gRPC generation command can be executed to generate a Java class library (implemented through protobuf compilation).

[0061] Point 4, through the newly implemented Thrift converter generator ( Figure 2 The diagram illustrates how to generate converters for all Thrift structures by creating a Thrift converter component (which generates a Thrift converter). These methods can then be called to convert Thrift data into corresponding gRPC data, which will be returned to the client as return values.

[0062] Point 5, via gRPC converter generator ( Figure 2 The diagram illustrates how to generate converters for all gRPC structures by creating a gRPC converter component (which generates a gRPC converter). These methods can then be called to convert gRPC data into corresponding Thrift data, which will be sent as request parameters to the service that processes the business.

[0063] Point 6: All gRPC services are generated through the gRPC service generator, and each service implements the corresponding gRPC interface. The interface is implemented by converting the data to Thrift data using a Thrift converter to request the Thrift service's interface, then converting the Thrift service's interface return value back to gRPC data using the gRPC converter, and finally returning it to the requesting client.

[0064] The gRPC service generator in the embodiment of the application can generate all gRPC services, and the generation manner is that: the gRPC interface corresponding to the implementation class of each service is implemented, the implementation manner is that the Thrift converter is used to convert the Thrift data to request the interface of the Thrift service, then the gRPC converter is used to convert the return value of the interface of the Thrift service back to the gRPC data, and finally the return value is returned to the request end.

[0065] The generated service in the embodiment of the application can also receive a gRPC request, and then convert the gRPC request into Thrift data (the interface parameters defined by Thrift) through the converter in the second point to request the interface of the service defined by Thrift (the service is a service for processing business logic), and then convert the return value of the interface of the Thrift service back to the gRPC data through the converter in the second point, and finally return the return value to the request end.

[0066] The application will be described below in combination with another alternative embodiment.

[0067] Embodiment two

[0068] The embodiment of the application provides a programming language library generation device, and each implementation unit included in the generation device corresponds to each step in the above embodiment one.

[0069] Figure 3 Fig. 1 is a schematic diagram of an alternative programming language library generation device according to the embodiment of the application, as shown in the figure, the generation device can include a receiving unit 31, a generating unit 33 and a calling unit 35, wherein, Figure 3 The receiving unit 31 is configured to receive a file conversion request, wherein the file conversion request carries file information and a remote procedure call command of a first type of remote procedure call library.

[0070] The generating unit 33 is configured to generate a protocol file of a second type of remote procedure call library based on the file information by using a pre-configured protocol generator.

[0071] The calling unit 35 is configured to execute the remote procedure call command, call the protocol file of the second type of remote procedure call library, and generate a programming language library.

[0072]

[0073] ​The generation apparatus of the programming language libraryapplicationreceive, through the receiving unit 31, a file conversion request, wherein the file conversion request carries file information and a remote procedure call command of the first type of remote procedure call library; generate, through the generating unit 33, a protocol file of the second type of remote procedure call library based on the file information by using a preconfigured protocol generator; execute, through the calling unit 35, the remote procedure call command to call the protocol file of the second type of remote procedure call library, and generate the programming language library. In this embodiment, when a migration request (or a conversion request, a calling request, etc.) between calling libraries is received, a protocol file of the second type of remote procedure call library can be generated based on file information by using a preconfigured protocol generator. The protocol generator can eliminate a large number of protocol definition migration and implementation processes, can quickly and automatically implement a migration protocol file, can improve the calling speed of file data, and can improve the file processing efficiency, thereby solving the technical problem of low efficiency in related technologies in which a protocol definition file is manually written to call file data.

[0074] Optionally, the generation apparatus of the programming language libraryapplicationfurther include a first obtaining module configured to obtain service interface information, structure information, and file basic information about the first type of remote procedure call library after receiving the file conversion request; a putting module configured to put the service interface information, the structure information, and the file basic information into a cache; a removing module configured to remove all dependent information structures in the service interface information, the structure information, and the file basic information in the cache in a newly created file to remove circular dependencies; and an induction module configured to induce the service interface information, the structure information, and the file basic information after the circular dependencies are removed into the file information.

[0075] Optionally, the file basic information includes at least one of a file version identifier, a referenced file, and a file package name; the service interface information includes at least one of a service name, all interface names, parameters, return values, and a request path; and the structure information includes at least one of a structure name, a structure attribute name, and a structure type.

[0076] Optionally, the generating unitapplicationinclude a splicing module configured to splice the service interface information, the structure information, and the file basic information respectively by using a preconfigured protocol generator to generate the protocol file of the second type of remote procedure call library.

[0077] Optionally, the generation method of the programming language libraryapplicationbe applied to a calling library converter.

[0078] Optionally, when constructing the call library converter, the process includes: creating an information object for the target programming language class; recording the class name and the package name of the file package in the information object; recording dependency references, field information, and conversion strategies in the information object, wherein the field information includes at least one of the following: type and name, and the conversion strategy includes at least one of the following: strategy name, return value, and parameters; and concatenating the package name, dependency references, class name, all field information, and all conversion strategies in sequence according to the specified format of the target programming language class.

[0079] Optionally, the first type of remote procedure call library is the gRPC library, and the second type of remote procedure call library is the Thrift library; or, the first type of remote procedure call library is the Thrift library, and the second type of remote procedure call library is the gRPC library.

[0080] The aforementioned programming language class library generation device may also include a processor and a memory. The aforementioned receiving unit 31, generating unit 33, calling unit 35, etc., are all stored in the memory as program units, and the processor executes the aforementioned program units stored in the memory to realize the corresponding functions.

[0081] The aforementioned processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured; by adjusting kernel parameters, remote procedure call commands are executed, invoking the protocol file of the second type of remote procedure call library to generate programming language class libraries.

[0082] The aforementioned memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0083] According to another aspect of the present invention, an electronic device is also provided, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute a method for generating a programming language class library of any of the above-mentioned methods by executing the executable instructions.

[0084] According to another aspect of the present invention, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored computer program, wherein, when the computer program is running, it controls the device where the computer-readable storage medium is located to execute the method for generating a programming language class library of any of the above-mentioned methods.

[0085] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program with the following initialization steps: receiving a file conversion request, wherein the file conversion request carries file information of a first type of remote procedure call library and a remote procedure call command; using a pre-configured protocol generator, generating a protocol file of a second type of remote procedure call library based on the file information; executing the remote procedure call command, calling the protocol file of the second type of remote procedure call library, and generating a programming language class library.

[0086] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0087] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0088] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0089] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0090] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0091] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0092] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for generating a programming language class library, characterized in that, include: Receive a file conversion request, wherein the file conversion request carries file information of a first type of remote procedure call library and remote procedure call commands, and the file conversion request is used to convert protocol files of different types of remote procedure call libraries to each other; A pre-configured protocol generator is used to generate a protocol file for the second type of remote procedure call library based on the file information; Execute the remote procedure call command to invoke the protocol file of the second type of remote procedure call library and generate a programming language class library; After receiving the file conversion request, it also includes: Obtain service interface information, structure information, and basic file information about the first type of remote procedure call library; The service interface information, the structure information, and the file basic information are placed in the cache; The service interface information, the structure information, and all dependent information structures in the file base information in the cache are placed in a new file to remove circular dependencies; The service interface information, the structure information, and the file basic information after removing circular dependencies are summarized into the file information; The step of generating a protocol file for a second type of remote procedure call library based on the file information using a pre-configured protocol generator includes: A pre-configured protocol generator is used to concatenate the service interface information, the structure information, and the file basic information to generate a protocol file for the second type of remote procedure call library.

2. The generation method according to claim 1, characterized in that, The basic file information includes at least one of the following: file version identifier, referenced file, and file package name; the service interface information includes at least one of the following: service name, all interface names, parameters, return value, and request path; the structure information includes at least one of the following: structure name, structure attribute name, and structure type.

3. The generation method according to any one of claims 1 to 2, characterized in that, The methods for generating programming language class libraries are applied to call library converters.

4. The generation method according to claim 3, characterized in that, When constructing the call library converter, the following are included: Create an information object of the target programming language class; Record the class name and the package name of the file package into the information object; Dependency references, field information, and conversion strategies are recorded in the information object, wherein the field information includes at least one of the following: type and name, and the conversion strategy includes at least one of the following: strategy name, return value, and parameters; Concatenate the package name, dependency references, class name, all field information, and all conversion strategies in the specified format of the target programming language class.

5. The generation method according to claim 1, characterized in that, The first type of remote procedure call library is a gRPC library, and the second type of remote procedure call library is a Thrift library; or, the first type of remote procedure call library is a Thrift library, and the second type of remote procedure call library is a gRPC library.

6. A device for generating a programming language class library, characterized in that, include: A receiving unit is used to receive a file conversion request, wherein the file conversion request carries file information of a first type of remote procedure call library and remote procedure call commands, and the file conversion request is used to convert protocol files of different types of remote procedure call libraries to each other; The generation unit is used to generate a protocol file for the second type of remote procedure call library based on the file information using a pre-configured protocol generator. The calling unit is used to execute the remote procedure call command, call the protocol file of the second type of remote procedure call library, and generate a programming language class library; The apparatus further includes: a first acquisition module, configured to acquire service interface information, structure information, and file basic information about the first type of remote procedure call library after receiving a file conversion request; an placement module, configured to place the service interface information, structure information, and file basic information into a cache; a removal module, configured to place all dependent information structures of the service interface information, structure information, and file basic information in the cache into a newly created file to remove circular dependencies; and a summarization module, configured to summarize the service interface information, structure information, and file basic information after removing circular dependencies into the file information. The generation unit includes a splicing module, which uses a pre-configured protocol generator to splice the service interface information, the structure information, and the file basic information to generate a protocol file for the second type of remote procedure call library.

7. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the method for generating a programming language class library according to any one of claims 1 to 5 by executing the executable instructions.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the method for generating a programming language class library as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Remote calling method and device and electronic equipment

    CN110187983A