Microservice code management method and device, electronic equipment and storage medium
By storing and managing microservice codes in a single code repository, the problem of excessive code duplication between microservices is solved, and efficient project compilation and release are achieved.
Patent Information
- Application Number
- CN202510899422.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-09-26
AI Technical Summary
Under the existing microservice architecture, the code duplication between microservices is too high, resulting in low project compilation efficiency, and the need for customized interface definition language documents for remote calls, which affects project compilation efficiency.
Store all microservice self-use program codes and general service program codes in a single code repository, create corresponding call entries, and perform archive management to avoid repeated configuration and remote calls, and use local references to obtain dependent microservice codes.
It reduces code duplication between microservices, improves the efficiency of project release and compilation, reduces the need for customized interface definition language documents, and improves the efficiency of project compilation and release.
Smart Images

Figure CN120704690A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of Internet technology, and in particular to a microservice code management method, device, electronic device, storage medium, and program product. Background Art
[0002] Projects under the microservice architecture integrate multiple types of microservices, such as advertising creation projects, which can include inventory microservices, planning microservices, material microservices, etc. In related technologies, the microservice codes corresponding to each type of microservice are stored in their respective code repositories. In addition to the self-use program codes required to implement their own microservice business functions, the code repositories also contain corresponding general service program codes (such as interface layer codes, logging codes, etc.), resulting in excessive code duplication between microservices. In addition, for the self-use program codes corresponding to other dependent microservices, it is necessary to customize the interface definition language documents and make remote calls, which affects the compilation efficiency of the project. Summary of the Invention
[0003] In view of this, the present disclosure provides a microservice code management method, device, electronic device and storage medium to solve the problem that the existing microservice code management method leads to excessive code duplication between microservices and low calling efficiency between microservices, which in turn affects the project compilation efficiency.
[0004] In a first aspect, the present disclosure provides a microservice code management method, which is applied to a microservice code management system, and the microservice code management system is configured with a single code repository; the method includes: obtaining the general service program code corresponding to the microservice required for the project to be created and the microservice self-use program code corresponding to the microservice; storing the general service program code and the microservice self-use program code in the single code repository; creating a corresponding microservice self-use program code call entry for the microservice self-use program code in the single code repository, and creating a corresponding general service program code call entry for the general service program code in the single code repository; archiving and managing the created project program entry corresponding to the project to be created, the call entry of the microservice self-use program code, and the call entry of the general service program code.
[0005] In a second aspect, the present disclosure provides a microservice code management device, which is applied to a microservice code management system, and the microservice code management system is configured with a single code repository; the device includes: a first acquisition module, which is used to obtain the general service program code corresponding to the microservice required for the project to be created and the microservice self-use program code corresponding to the microservice; a storage module, which is used to store the general service program code and the microservice self-use program code in the single code repository; a creation module, which is used to create a calling entry of the corresponding microservice self-use program code for the microservice self-use program code in the single code repository, and to create a calling entry of the corresponding general service program code for the general service program code in the single code repository; an archiving module, which is used to archive and manage the created project program entry corresponding to the project to be created, the calling entry of the microservice self-use program code, and the calling entry of the general service program code.
[0006] In a third aspect, the present disclosure provides an electronic device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the microservice code management method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0007] In a fourth aspect, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the microservice code management method of the first aspect or any corresponding embodiment thereof.
[0008] In a fifth aspect, the present disclosure provides a computer program product, including computer instructions, which are used to enable a computer to execute the microservice code management method of the above-mentioned first aspect or any corresponding embodiment thereof.
[0009] The microservice code management method provided by the embodiment of the present disclosure is applied to a microservice code management system configured with a single code repository. By storing the self-use program code of each microservice required for project creation and the general service program code shared by all microservices in the same code repository, and archiving the call entry corresponding to the program code in the code repository and the project program entry, the same general service program code can be directly called when compiling the microservice corresponding to the created project, avoiding the repeated configuration of the public general service program code in different code repositories and reducing the code duplication between microservices. At the same time, when each microservice in the process of compiling and publishing the project needs to be compiled, the corresponding self-use program code, the general service program code required for compilation and the self-use program code of other microservices that depend on it can be directly obtained from the same code repository, avoiding the need to customize the corresponding interface definition language document and perform remote calls for other dependent microservices during the compilation process. Instead, the acquisition operation of the dependent microservice code can be achieved by directly using local reference in the same code repository, thereby improving the release and compilation efficiency of the project. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the related technologies, the following briefly introduces the drawings required for use in the specific embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0011] Figure 1 1 is a flowchart of a microservice code management method according to an embodiment of the present disclosure;
[0012] Figure 2A is a schematic diagram corresponding to the microservice code management method according to an embodiment of the present disclosure;
[0013] Figure 2B is a schematic diagram corresponding to the microservice code management method according to an embodiment of the present disclosure;
[0014] Figure 2C is a schematic diagram corresponding to the microservice code management method according to an embodiment of the present disclosure;
[0015] Figure 3 is a structural block diagram of a microservice code management device according to an embodiment of the present disclosure;
[0016] Figure 4 Schematic diagram of the hardware structure of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0017] To make the purpose, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of the present disclosure.
[0018] It is understandable that before using the technical solutions disclosed in the various embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0019] For example, in response to a user's active request, a prompt message is sent to the user to clearly inform the user that the operation requested will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the electronic device, application, server, storage medium, or other software or hardware that performs the operations of the disclosed technical solution based on the prompt message.
[0020] As an optional but non-limiting implementation, in response to receiving a user's active request, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. Furthermore, the pop-up window may also contain a selection control for the user to select "agree" or "disagree" to provide personal information to the electronic device.
[0021] It is understandable that the above notification and user authorization process are merely illustrative and do not limit the implementation of the present disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0022] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) must comply with the requirements of relevant laws, regulations and relevant provisions.
[0023] Different projects under the microservice architecture correspond to multiple types of microservices. For example, for an advertising creation project, it can include inventory microservices, planning microservices, creative microservices, material microservices, etc. In related technologies, the microservice code corresponding to each type of microservice is stored in its own code repository. In addition to containing the self-use program code required to implement the business functions of its own microservice, the code repository also contains corresponding general service program code (such as interface layer code, logging code, etc.). Taking the inventory microservice, planning microservice, creative microservice, and material microservice under the advertising creation project as an example, the code repositories corresponding to the inventory microservice, planning microservice, creative microservice, and material microservice in the relevant technology are all configured with public general service program codes, and for each type of microservice compilation, the other microservice self-use program codes that it depends on need to customize the interface definition language document (IDL) and be obtained through remote calls; for example, for the inventory microservice, the other microservice self-use program codes it depends on include the planning microservice self-use program code and the creative microservice self-use program code; for the planning microservice, the other microservice self-use program codes it depends on include the inventory microservice self-use program code, the creative microservice self-use program code, and the material microservice self-use program code; for the material microservice, the other microservice self-use program codes it depends on include the inventory microservice self-use program code, the planning microservice self-use program code, and the like; it can be seen that for each microservice, it depends on many types of microservices, and all need to be remotely called by combining IDL and the corresponding code call entry, which affects the compilation and creation efficiency of the project.
[0024] According to an embodiment of the present disclosure, an embodiment of a microservice code management method is provided. It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0025] In this embodiment, a microservice code management method is provided, which is applied to a microservice code management system. The microservice code management system is configured with a single code repository for storing all microservice self-use program codes corresponding to the project to be created and the public general service program codes corresponding to the microservices. Figure 1 is a flowchart of a microservice code management method according to an embodiment of the present disclosure. Figure 1 As shown, the process includes the following steps:
[0026] Step S101: Obtain the general service program code corresponding to the microservice required by the project to be created and the microservice self-use program code corresponding to the microservice.
[0027] For example, taking the advertising creation project as an example, if the microservices required for the advertising creation project include inventory microservice, planning microservice, creative microservice, and material microservice, the microservice self-use program code corresponding to each microservice required for the advertising creation project is obtained, that is, the inventory microservice self-use program code, planning microservice self-use program code, creative microservice self-use program code, and material microservice self-use program code are obtained. The general service program code corresponding to each microservice can be configured from the perspectives of business logic, technical architecture, and functional reuse requirements based on the microservice publishing requirements, such as log services, configuration management services, cache services, database operation services, communication services, message queue services, authority and security services, alarm services, etc. Those skilled in the art can select and configure according to the specific microservice compilation and publishing requirements; for the advertising creation project scenario of the embodiment of the present application, the corresponding general service program code is the general service program code corresponding to the general service commonly required by the inventory microservice, planning microservice, creative microservice, and material microservice.
[0028] Step S102: Store the general service program code and the microservice self-use program code in a single code repository.
[0029] Step S103: creating a corresponding microservice self-use program code call entry for the microservice self-use program code in the single code repository, and creating a corresponding general service program code call entry for the general service program code in the single code repository.
[0030] For example, a corresponding call entry is created for each microservice self-use program code in a single code repository, and a corresponding call entry is created for the general service program code in the single code repository. The embodiment of the present application does not limit the creation method of the call entry corresponding to the program code. For example, the call entry of the microservice self-use program corresponding to the inventory microservice of the advertising creation project can be "ad.brand.stock_rpc", the call entry of the microservice self-use program corresponding to the planning microservice can be "ad.brand.ad_rpc", the call entry of the microservice self-use program corresponding to the creative microservice can be "ad.brand.creative_rpc", and the call entry of the microservice self-use program corresponding to the material microservice can be "ad.brand.material_rpc". The call entry corresponding to the general service program code can be packaged and configured in a targeted manner according to the type of general service. Establish an association between the call entry of the created program code and the corresponding program code.
[0031] Step S104 , archiving and managing the project program entry corresponding to the project to be created, the calling entry of the microservice self-use program code, and the calling entry of the general service program code.
[0032] For example, the project program entry corresponding to the project to be created, the calling entry for the microservice's own program code, and the calling entry for the general service program code can be archived, such as being written into the same file for standardized organization and storage. This facilitates the direct retrieval of the corresponding program code's calling entry from the corresponding file during subsequent project compilation and release, enabling the retrieval and reuse of the corresponding program code. Through the project program entry, the main program of the entire service can be enabled when the project is compiled and released. After entering the main program, the corresponding code can be retrieved from the corresponding calling entry based on the compilation requirements of any microservice to implement the compilation operation of the corresponding microservice.
[0033] The microservice code management method provided in this embodiment stores each microservice self-use program code required for project creation and the general service program code shared by all microservices in the same code repository, and archives the calling entry and project program entry corresponding to the program code in the code repository, so that when compiling the microservice corresponding to the project to be created, the same general service program code can be directly called, avoiding the repeated configuration of public general service program code in different code repositories, and reducing the code duplication between microservices; at the same time, when compiling each microservice in the process of compiling and publishing the project, the corresponding self-use program code, the general service program code required for compilation, and the self-use program code of other microservices that depend on it can be directly obtained from the same code repository, avoiding the need to customize the corresponding interface definition language document and perform remote calls for other dependent microservices during the compilation process. Instead, the acquisition operation of the dependent microservice code can be achieved by directly using local reference in the same code repository, thereby improving the release and compilation efficiency of the project.
[0034] In some optional implementations, the above step S104 includes: archiving and managing the project program entry corresponding to the project to be created, the calling entry of the microservice self-use program code, and the calling entry of the general service program code according to the directory structure.
[0035] Exemplarily, an embodiment of the present application can use a command line tool (such as tree) to archive and manage the project program entry corresponding to the project to be created, the calling entry of the microservice self-use program code, and the calling entry of the general service program code according to the directory structure, so that after archiving according to the directory structure, the hierarchical relationship between the project program entry, the calling entry of the microservice self-use program code, and the general service program code can be clarified, such as taking the project program entry corresponding to the project to be created as the parent directory of the directory structure, and taking the calling entry of the microservice self-use program code and the calling entry of the general service program code as subdirectories under the parent directory.
[0036] In some optional implementations, the project program entry corresponding to the project to be created, the calling entry of the microservice self-use program code, and the calling entry of the general service program code are archived and managed according to the directory structure, including: the project program entry corresponding to the project to be created and the calling entry of the general service program code are used as parent directories in the directory structure; and the calling entry of the microservice self-use program code is used as a subdirectory under the parent directory corresponding to the project program entry.
[0037] For example, the specific example is Figure 2A As shown, the project program entry corresponding to the project to be created and the calling entry of the general service program code are used as the parent directory in the directory structure, and the calling entry 1 of the microservice self-use program code (such as the calling entry of the material microservice self-use program code), the calling entry 2 of the microservice self-use program code (such as the calling entry of the inventory microservice self-use program code), the calling entry 3 of the microservice self-use program code (such as the calling entry of the order microservice self-use program code) and the calling entry 4 of the microservice self-use program code (such as the calling entry of the interface layer microservice self-use program code) are used as subdirectories under the parent directory corresponding to the project program entry.
[0038] In some optional implementations, the general service program code includes codes corresponding to multiple types of general services, and the call entry of the general service program code includes a call entry corresponding to each type of general service; see Figure 2B As shown, in the embodiment of the present application, the call entry of 5 general services is taken as an example, namely the call entry 1 of the general service program code, the call entry 2 of the general service program code, the call entry 3 of the general service program code, the call entry 4 of the general service program code and the call entry 5 of the general service program code, which can respectively correspond to the reusable configuration service, the reusable model layer service, the reusable Infra service, the reusable toolkit and the reusable service service. The embodiment of the present application does not limit the type of specific general service. The method also includes: using the call entry corresponding to each type of general service as the parent directory in the directory structure, so that each type of general service is displayed in a detailed manner in the directory structure, which facilitates the acquisition and reuse of the corresponding type of general service code during microservice compilation, thereby improving compilation efficiency.
[0039] In some optional implementations, the method also includes: when there are multiple types of projects to be created, the project program entry corresponding to each project to be created is used as the parent directory in the directory structure; the calling entry of the microservice self-use program code of each microservice required by the project to be created is used as a sub-directory under the parent directory corresponding to the corresponding project program entry; the calling entry of the general service program code corresponding to each project to be created is merged in a union manner, and the calling entry of the general service program code obtained by the merge is used as the parent directory in the directory structure.
[0040] For example, specifically Figure 2C As shown, it includes project program entry 1 and project program entry 2 corresponding to the two projects to be created. Each parent directory contains the call entry corresponding to the self-use program code under the corresponding project to be created as a subdirectory. The call entry of the public general service program code corresponding to the microservice required by each project to be created is merged in a union manner to reduce the storage space occupied by the public general service program code under different projects in a single code repository, and the call entry of the general service program code obtained by the merger is merged. Figure 2C The general service program code calling entry 1A, the general service program code calling entry 2A, the general service program code calling entry 3A, the general service program code calling entry 4A, and the general service program code calling entry 5A contained in the general service program code as the parent directory in the directory structure are the calling entries of multiple general service program codes obtained after the merger, which can be specifically the common business logic layer service, reusable configuration service and reusable model layer service under multiple project program entries, reusable Infra service, reusable toolkit or reusable service service, etc. The embodiment of the present application does not limit the specific general service type.
[0041] The number and type of calling entries for the microservice self-use program code and the number and type of calling entries corresponding to the general service program code in the above embodiment are only for illustration. Those skilled in the art can perform selective configuration and directory structure generation according to actual project creation requirements.
[0042] In some optional embodiments, the method further includes: upon receiving a compilation request for a target executable code corresponding to any target microservice in the project to be created, obtaining the corresponding first microservice self-use program code according to the calling entry of the microservice self-use program code corresponding to the target microservice; and responding to the compilation operation of the target executable code according to the microservice construction logic information and the first microservice self-use program code corresponding to the target microservice.
[0043] For example, during the construction of an advertising creation project, the target microservice to be compiled and released can be determined based on the received environment variables, and the corresponding microservice self-use program code, i.e., the first microservice self-use program code, can be obtained based on the calling entry of the microservice self-use program code corresponding to the target microservice. Then, based on the microservice construction logic information corresponding to the target microservice and the first microservice self-use program code, the compilation operation of the target executable code is responded to. In the embodiment of the present application, the target microservice is an inventory microservice as an example. When a compilation request for the target executable code corresponding to the inventory microservice is received, the compilation operation can be performed on the corresponding target executable code based on the dependency installation rules, code generation rules, and compilation parameters contained in the microservice construction logic information corresponding to the inventory microservice and the first microservice self-use program code.
[0044] In some optional implementations, responding to a compilation operation on a target executable code based on the microservice construction logic information and the first microservice self-use program code corresponding to the target microservice includes: obtaining the corresponding general service program code from a calling entry of a general service of the corresponding type based on the general service type configuration information contained in the microservice construction logic information; obtaining the second microservice self-use program code corresponding to the other microservice from a calling entry of the microservice self-use program code corresponding to the corresponding other microservice based on other microservice type configuration information on which the target microservice depends contained in the microservice construction logic information; and performing a compilation operation on the target executable code based on the microservice construction logic information and the obtained first microservice self-use program code, general service program code, and second microservice self-use program code.
[0045] Exemplarily, through the build rules (such as Makefile) contained in the predefined microservice build logic information, the source code of the microservice (including the first microservice self-use program code, the general service program code and the second microservice self-use program code) is compiled into an executable file corresponding to the target microservice and the compiled target executable file is subsequently released, tested and other operations are performed. In the embodiment of the present application, the target microservice is the inventory microservice as an example. When a compilation request for the target executable code corresponding to the inventory microservice is received, the general service program code required for the compilation of the inventory microservice is obtained from the calling entry of the corresponding type of general service according to the general service type configuration information contained in the microservice construction logic information. According to the other microservice type configuration information on which the target microservice depends contained in the microservice construction logic information, the second microservice self-use program code corresponding to the other microservice is obtained from the calling entry of the microservice self-use program code corresponding to the corresponding other microservice. That is, for the inventory microservice, the other microservices it depends on may include a planning microservice and a creative microservice, that is, the self-use program code corresponding to the planning microservice and the self-use program code corresponding to the creative microservice are obtained, and then the compilation operation is performed on the target executable code according to the dependency installation rules, code generation rules, compilation parameters and other information contained in the microservice construction logic information and the obtained first microservice self-use program code, general service program code and second microservice self-use program code.
[0046] The microservice code management method provided in the embodiment of the present application constructs a framework for unified management of multiple microservices (such as Go services). Through reasonable directory structure planning, such as concentrating multiple microservices and general services in one warehouse and managing them through the directory structure, the project team can browse and manage the code globally based on the directory structure, without the need to frequently switch between multiple code repositories, reducing the time for finding code and processing dependencies; and the unified directory structure and dependency management enable new project members to become familiar with the project more quickly, reduce learning costs, and improve overall development efficiency. The public libraries and tools under general services can also be conveniently shared and reused by multiple microservices; at the same time, the unified maintenance of project code also reduces problems caused by code inconsistencies, and the unified code warehouse and development process make it easier for developers to conduct code reviews, problem discussions and function integration, reducing communication costs and improving the efficiency of team collaboration.
[0047] In this embodiment, a microservice code management device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation methods. The details that have been described will not be repeated here. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
[0048] This embodiment provides a microservice code management device, which is applied to a microservice code management system. The microservice code management system is configured with a single code repository; Figure 3 As shown, including:
[0049] The first acquisition module 201 is used to obtain the general service program code corresponding to the microservice required by the project to be created and the microservice self-use program code corresponding to the microservice;
[0050] Storage module 202, used to store general service program code and microservice self-use program code in a single code repository;
[0051] A creation module 203 is used to create a call entry for the corresponding microservice self-use program code in the single code repository, and to create a call entry for the corresponding general service program code in the single code repository;
[0052] The archiving module 204 is used to archive and manage the project program entry corresponding to the created project to be created, the calling entry of the microservice self-use program code, and the calling entry of the general service program code.
[0053] The microservice code management device provided by this embodiment stores each microservice self-use program code required for project creation and the general service program code shared by all microservices in the same code repository, and archives the calling entry and project program entry corresponding to the program code in the code repository, so that when compiling the microservice corresponding to the project to be created, the same general service program code can be directly called, avoiding the repeated configuration of public general service program code in different code repositories, and reducing the code duplication between microservices; at the same time, when compiling each microservice in the process of compiling and publishing the project, the corresponding self-use program code, the general service program code required for compilation, and the self-use program code of other microservices that depend on it can be directly obtained from the same code repository, avoiding the need to customize the corresponding interface definition language document and perform remote calls for other dependent microservices during the compilation process. Instead, the acquisition operation of the dependent microservice code can be achieved by directly using local reference in the same code repository, thereby improving the release and compilation efficiency of the project.
[0054] In some optional implementations, the archiving module includes: an archiving sub-module, which is used to archive and manage the project program entry corresponding to the created project, the calling entry of the microservice self-use program code, and the calling entry of the general service program code according to the directory structure.
[0055] In some optional embodiments, the archiving sub-module includes: a first archiving unit, which is used to use the project program entry corresponding to the project to be created and the calling entry of the general service program code as the parent directory in the directory structure; a second archiving unit, which is used to use the calling entry of the microservice self-use program code as a subdirectory under the parent directory corresponding to the project program entry.
[0056] In some optional embodiments, the general service program code includes codes corresponding to multiple types of general services, and the calling entry of the general service program code includes the calling entry corresponding to each type of general service; the device also includes: a third archiving unit, which is used to use the calling entry corresponding to each type of general service as the parent directory in the directory structure.
[0057] In some optional embodiments, the device also includes: a fourth archiving unit, which is used to use the project program entry corresponding to each project to be created as a parent directory in the directory structure when there are multiple types of projects to be created; a fifth archiving unit, which is used to use the calling entry of the microservice self-use program code of each microservice required by the project to be created as a subdirectory under the parent directory corresponding to the corresponding project program entry; and a sixth archiving unit, which is used to merge the calling entry of the general service program code corresponding to each project to be created in a union manner, and use the calling entry of the general service program code obtained by the merge as the parent directory in the directory structure.
[0058] In some optional embodiments, the device also includes: a second acquisition module, which is used to obtain the corresponding first microservice self-use program code according to the calling entry of the microservice self-use program code corresponding to the target microservice when receiving a compilation request for the target executable code corresponding to any target microservice in the project to be created; and a compilation module, which is used to respond to the compilation operation of the target executable code according to the microservice construction logic information and the first microservice self-use program code corresponding to the target microservice.
[0059] In some optional embodiments, the compilation module includes: a first acquisition sub-module, which is used to obtain the corresponding general service program code from the calling entry of the corresponding type of general service according to the general service type configuration information contained in the microservice construction logic information; a third acquisition sub-module, which is used to obtain the second microservice self-use program code corresponding to the other microservice from the calling entry of the microservice self-use program code corresponding to the corresponding other microservice according to the other microservice type configuration information on which the target microservice depends contained in the microservice construction logic information; and a compilation sub-module, which is used to perform a compilation operation on the target executable code according to the microservice construction logic information and the obtained first microservice self-use program code, general service program code and second microservice self-use program code.
[0060] The microservice code management device provided in the embodiments of the present disclosure can execute the microservice code management method provided in any embodiment of the present disclosure, and has the functional modules and beneficial effects corresponding to the execution method. The further functional description of each of the above modules and units is the same as that of the corresponding embodiment above, and will not be repeated here.
[0061] Figure 4 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure.
[0062] The following specific reference Figure 4 , which shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure. The electronic device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a memory 508 into a random access memory (RAM) 503. Various programs and data required for the operation of the electronic device are also stored in the RAM 503. The processor 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0063] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all of the devices shown, and more or fewer devices may be implemented or possessed instead.
[0064] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the memory 508, or installed from the ROM 502. When the computer program is executed by the processor 501, the above-mentioned functions defined in the microservice code management method of the embodiment of the present disclosure are performed.
[0065] Figure 4The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0066] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or implemented as a computer code that can be recorded in a storage medium, or implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the microservice code management method shown in the above embodiment is implemented.
[0067] A portion of the present disclosure may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present disclosure through the operation of the computer. Those skilled in the art should understand that the form in which the computer program instruction exists in a computer-readable medium includes but is not limited to a source file, an executable file, an installation package file, etc. Accordingly, the way in which the computer program instruction is executed by the computer includes but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium that can be accessed by the computer.
[0068] Although the embodiments of the present disclosure have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A microservice code management method, characterized in that: Applied to microservice code management system, which is configured with a single code repository; The method comprises: Obtain the general service program code corresponding to the microservice required for the project to be created and the microservice self-use program code corresponding to the microservice; Storing the general service program code and the microservice self-use program code in a single code repository; Creating a corresponding microservice self-use program code call entry for the microservice self-use program code in the single code repository, and creating a corresponding general service program code call entry for the general service program code in the single code repository; The project program entry corresponding to the to-be-created project, the calling entry of the microservice self-use program code, and the calling entry of the general service program code are archived and managed.
2. The method according to claim 1, characterized in that The archiving management of the project program entry corresponding to the to-be-created project, the calling entry of the microservice self-use program code, and the calling entry of the general service program code includes: The project program entry corresponding to the project to be created, the calling entry of the microservice self-use program code, and the calling entry of the general service program code are archived and managed according to the directory structure.
3. The method according to claim 2, characterized in that The project program entry corresponding to the project to be created, the calling entry of the microservice self-use program code, and the calling entry of the general service program code are archived and managed according to the directory structure, including: The project program entry corresponding to the project to be created and the calling entry of the general service program code are used as the parent directory in the directory structure; The calling entry of the microservice self-use program code is used as a subdirectory under the parent directory corresponding to the project program entry.
4. The method according to claim 3, characterized in that The general service program code includes codes corresponding to multiple types of general services, and the calling entry of the general service program code includes a calling entry corresponding to each type of general service; The method further comprises: The call entry corresponding to each type of universal service is used as the parent directory in the directory structure.
5. The method according to claim 2, characterized in that The method further comprises: When there are multiple types of projects to be created, the project program entry corresponding to each of the projects to be created is used as a parent directory in the directory structure; The calling entry of the microservice self-use program code corresponding to each of the projects to be created is used as a subdirectory under the parent directory corresponding to the corresponding project program entry; The calling entry of the universal service program code corresponding to each of the to-be-created projects is merged in a union manner, and the calling entry of the universal service program code obtained by the merging process is used as the parent directory in the directory structure.
6. The method according to claim 4, characterized in that The method further comprises: When receiving a compilation request for a target executable code corresponding to any target microservice in the project to be created, obtaining the corresponding first microservice self-use program code according to the calling entry of the microservice self-use program code corresponding to the target microservice; The target executable code is responded to based on the microservice construction logic information corresponding to the target microservice and the first microservice self-use program code.
7. The method according to claim 6, characterized in that The step of responding to the compilation operation of the target executable code based on the microservice construction logic information corresponding to the target microservice and the first microservice self-use program code includes: Obtaining corresponding general service program code from a call entry of a corresponding type of general service according to the general service type configuration information included in the microservice construction logic information; According to the configuration information of other microservice types on which the target microservice depends, which is included in the microservice construction logic information, obtaining the second microservice self-use program code corresponding to the other microservice from the calling entry of the microservice self-use program code corresponding to the corresponding other microservice; A compilation operation is performed on the target executable code according to the microservice construction logic information and the acquired first microservice self-use program code, general service program code, and second microservice self-use program code.
8. A microservice code management device, characterized in that: Applied to microservice code management system, which is configured with a single code repository; The device comprises: The first acquisition module is used to obtain the general service program code corresponding to the microservice required by the project to be created and the microservice self-use program code corresponding to the microservice; A storage module, configured to store the general service program code and the microservice self-use program code in a single code repository; A creation module, configured to create a calling entry for the corresponding microservice self-use program code for the microservice self-use program code in the single code repository, and to create a calling entry for the corresponding general service program code for the general service program code in the single code repository; The archiving module is used to archive and manage the project program entry corresponding to the project to be created, the calling entry of the microservice self-use program code, and the calling entry of the general service program code.
9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the microservice code management method according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the microservice code management method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the microservice code management method according to any one of claims 1 to 7.