Database calling method, device and computer equipment
By setting up database calling components in the microservice architecture and calling data services of preset databases, the problems of bloated functions and high failure rates of microservice components are solved, and the effect of reducing coupling and improving maintainability is achieved.
Patent Information
- Application Number
- CN201910750856.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-08-14
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2039-08-14
AI Technical Summary
In a microservice architecture, microservice components need to implement multiple functions, resulting in bloated functions, high failure rate, and are not easy to maintain.
By setting up database calling components in the microservice architecture, calling data services of preset databases, reducing component coupling and improving maintainability. The specific methods include obtaining the service name of the database calling component, obtaining the access address, and running the database calling component to call the data service of the preset database, and avoiding the convergence of multiple business functions in the same component.
It realizes the reduction of coupling between microservice components, improves the maintainability of components, avoids component bloat problems, and improves the flexibility and stability of the system.
Smart Images

Figure CN110716811B_ABST
Abstract
Description
[Technical field]
[0001] The present application relates to the field of cloud computing technology, and in particular to a database calling method, device and computer equipment. [Background technology]
[0002] Microservice architecture is an architectural concept. Its main function is to decompose the functions of a business system into discrete services, thereby reducing the coupling of the business system and providing more flexible service support.
[0003] In the existing related technologies, microservice components in a microservice architecture generally need to implement at least two functions when processing business. For example, for the order-issuing component in the microservice architecture, when implementing the order-issuing function, it is also necessary to implement the function of calling the order-issuing database, which makes the order-issuing component too bloated. If the order-issuing component's order-issuing or order-calling database function fails, the entire order-issuing component will be unusable and difficult to maintain later. [Summary of the invention]
[0004] The embodiments of the present application provide a database calling method, apparatus and computer device to call the data service of a preset database through a database calling component set in a microservice architecture, thereby avoiding the component bloat problem caused by integrating multiple business functions into the same microservice component, reducing the coupling between microservice components, and improving the maintainability of microservice components.
[0005] In a first aspect, an embodiment of the present application provides a database calling method, comprising: obtaining a service name of a database calling component in a microservice architecture, wherein the database calling component is a microservice component pre-set in the microservice architecture, and the database calling component is used to call a data service of a preset database; according to the service name of the database calling component, obtaining an access address of the database calling component from a service discovery component of the microservice architecture; and according to the access address, running the database calling component to call the data service of the preset database.
[0006] In one possible implementation, running the database calling component according to the access address to call the data service of the preset database includes: configuring the access address into a request method for running the database calling component; and executing the request method to call the data service of the preset database.
[0007] In the second aspect, an embodiment of the present application provides a database calling method, including: obtaining a microservice component that needs to call a preset database in a microservice architecture; extracting a logic code for calling a data service of the preset database from the microservice component that needs to call the preset database; deploying a corresponding database calling component according to the extracted logic code; registering the service name and access address of the deployed database calling component in the service discovery component of the microservice architecture, so that the service calling component obtains the access address of the database calling component from the service discovery component according to the service name of the database calling component, and runs the database calling component according to the access address to call the data service of the preset database.
[0008] In one possible implementation, the deploying of the corresponding database call component according to the extracted logic code includes: obtaining a database call component, wherein the database call component is developed according to the request method and request parameters of the data in the preset database, and the request method and request parameters of the data in the preset database are obtained from the logic code; and deploying the database call component according to the deployment method of the microservice component.
[0009] In one possible implementation, the deploying of the database call component according to the deployment method of the microservice component includes: making an image file corresponding to the database call component; pushing the image file to a registered image library; and modifying the configuration file of the microservice architecture according to the database call component and the image file corresponding to the database call component.
[0010] In one possible implementation, registering the service name and access address of the deployed database call component in the service discovery component of the microservice architecture includes: obtaining the access address of the service discovery component from a configuration file of the microservice architecture; and registering the service name and access address of the database call component in the service discovery component according to the access address of the service discovery component.
[0011] In a third aspect, an embodiment of the present application provides a database calling device, which is arranged in a service calling component, and the database calling device includes: an acquisition module, used to obtain the service name of the database calling component in the microservice architecture, the database calling component is a microservice component pre-set in the microservice architecture, and the database calling component is used to call the data service of a preset database; and according to the service name of the database calling component, obtain the access address of the database calling component from the service discovery component of the microservice architecture; a calling module, used to run the database calling component according to the access address obtained by the acquisition module to call the data service of the preset database.
[0012] In one possible implementation, the calling module is specifically used to configure the access address into a request method for running the database calling component, and execute the request method to call the data service of the preset database.
[0013] In a fourth aspect, an embodiment of the present application provides a database calling device, which is arranged in a microservice component server, and the database calling device includes: an acquisition module, which is used to obtain a microservice component that needs to call a preset database in a microservice architecture; an extraction module, which is used to extract the logic code for calling the data service of the preset database from the microservice component that needs to call the preset database obtained by the acquisition module; a deployment module, which is used to deploy the corresponding database calling component according to the logic code extracted by the extraction module; a registration module, which is used to register the service name and access address of the database calling component deployed by the deployment module in the service discovery component of the microservice architecture.
[0014] In one possible implementation, the deployment module is specifically used to obtain a database call component and deploy the database call component according to the deployment method of the microservice component; the database call component is developed according to the request method and request parameters of the data in the preset database, and the request method and request parameters of the data in the preset database are obtained from the logic code.
[0015] In one possible implementation, the deployment module is specifically used to create an image file corresponding to the database call component, push the image file to a registered image library, and modify the configuration file of the microservice architecture according to the database call component and the image file corresponding to the database call component.
[0016] In one possible implementation, the registration module is specifically used to obtain the access address of the service discovery component from the configuration file of the microservice architecture; according to the access address of the service discovery component, the service name and access address of the database call component are registered in the service discovery component.
[0017] In a fifth aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method provided in the first aspect is implemented.
[0018] In a sixth aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method provided in the second aspect is implemented.
[0019] In a seventh aspect, an embodiment of the present application provides a non-temporary computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method provided in the first aspect is implemented.
[0020] In an eighth aspect, an embodiment of the present application provides a non-temporary computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method provided in the second aspect is implemented.
[0021] In the above technical solution, after obtaining the service name of the database call component in the microservice architecture, the access address of the database call component is obtained from the service discovery component of the microservice architecture according to the service name of the database call component; then, according to the access address, the database call component is run to call the data service of the preset database. Among them, the database call component is a microservice component pre-set in the microservice architecture, and the database call component is used to call the data service of the preset database, so that the data service of the preset database can be called by the database call component set in the microservice architecture, avoiding the component bloat problem caused by integrating multiple business functions into the same microservice component, reducing the coupling between microservice components, and improving the maintainability of microservice components.
Brief Description of the Drawings
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 A flowchart of an embodiment of a method for calling a database of the present application;
[0024] Figure 2 A flowchart of another embodiment of the method for calling the database of the present application;
[0025] Figure 3 A flowchart of another embodiment of the method for calling the database of the present application;
[0026] Figure 4 A flowchart of another embodiment of the method for calling the database of the present application;
[0027] Figure 5 A schematic diagram of the structure of an embodiment of a database calling device of the present application;
[0028] Figure 6This is a schematic diagram of the structure of another embodiment of the database calling device of the present application;
[0029] Figure 7 This is a schematic diagram of the structure of an embodiment of a computer device of the present application. [Specific implementation method]
[0030] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0031] It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0032] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0033] Figure 1 This is a flowchart of an embodiment of the method for calling the database of this application, such as Figure 1 As shown, the calling method of the above database may include:
[0034] Step 101, obtaining the service name of a database calling component in the microservice architecture, wherein the database calling component is a microservice component pre-set in the microservice architecture, and the database calling component is used to call a data service of a preset database.
[0035] The above-mentioned preset database may be a basic database or a database in other forms, and this embodiment does not limit the preset database.
[0036] The service name of the database calling component may be a HyperText Transfer Protocol (hereinafter referred to as HTTP) service name, and the service calling component may obtain the access address of the database calling component from the service discovery component of the microservice architecture through the HTTP service name. The service calling component here includes the microservice component in the microservice architecture that needs to call the database calling component.
[0037] Step 102: According to the service name of the database calling component, the access address of the database calling component is obtained from the service discovery component of the microservice architecture.
[0038] The service discovery component can be implemented using Eureka, which is a service discovery framework developed by Netflix. It is a service based on Representational State Transfer (REST). Its main function is to register microservice components. After the microservice components are registered on Eureka, the registered microservice components can be found through Eureka.
[0039] Specifically, when the HTTP service name is used to obtain the access address of the database calling component from the service discovery component, the service discovery component will find the access address corresponding to the HTTP service name from the service registration list based on the HTTP service name.
[0040] Step 103: Run the database calling component according to the access address to call the data service of the preset database.
[0041] Specifically, when the database calling component is run according to the access address, the service calling component also needs to pass in relevant parameters required for running the database calling component, which will not be described in detail here.
[0042] In the above-mentioned database calling method, after obtaining the service name of the database calling component in the microservice architecture, the access address of the above-mentioned database calling component is obtained from the service discovery component of the above-mentioned microservice architecture according to the service name of the above-mentioned database calling component; then, according to the above-mentioned access address, the above-mentioned database calling component is run to call the data service of the above-mentioned preset database. Among them, the above-mentioned database calling component is a microservice component pre-set in the microservice architecture, and the above-mentioned database calling component is used to call the data service of the preset database, so that the data service of the preset database can be called by the database calling component set in the microservice architecture, avoiding the component bloat problem caused by integrating multiple business functions in the same microservice component, reducing the coupling between microservice components, and improving the maintainability of microservice components.
[0043] Figure 2 This is a flowchart of another embodiment of the method for calling the database of the present application, such as Figure 2 As shown, this application Figure 1 In the illustrated embodiment, step 103 may include:
[0044] Step 201: configure the access address into the request method for running the database calling component.
[0045] In a specific implementation, when configuring the access address into the request method, the service calling component may also configure the relevant parameters required for running the database calling component into the request method.
[0046] Step 202: execute the request method to call the data service of the preset database.
[0047] Specifically, the service calling component may use the Socket protocol to execute the above request method. When the Socket protocol is used to execute the above request method, the HTTP protocol may be used to complete the call of the data service of the above preset database.
[0048] Figure 3 This is a flowchart of another embodiment of the method for calling the database of the present application, as shown in FIG. Figure 3 As shown, the calling method of the above database may include:
[0049] Step 301, obtain the microservice component that needs to call the preset database in the microservice architecture.
[0050] Step 302: extract the logic code for calling the data service of the preset database from the microservice component that needs to call the preset database.
[0051] Step 303: deploy corresponding database call components according to the extracted logic code.
[0052] Step 304, registers the service name and access address of the deployed database call component in the service discovery component of the above-mentioned microservice architecture, so that the service call component obtains the access address of the above-mentioned database call component from the above-mentioned service discovery component according to the service name of the above-mentioned database call component, and runs the above-mentioned database call component according to the above-mentioned access address to call the data service of the above-mentioned preset database.
[0053] In this embodiment, the microservice component server splits the microservice component into microservice components of smaller granularity, and deploys a database call component in the microservice architecture, which is specifically responsible for calling the preset database. This avoids the component bloat problem caused by integrating multiple business functions into the same microservice component, reduces the coupling between microservice components, and makes the business function of each microservice component clearer and easier to maintain.
[0054] Figure 4 This is a flowchart of another embodiment of the method for calling the database of the present application, as shown in FIG. Figure 4 As shown, this application Figure 3 In the illustrated embodiment, step 303 may include:
[0055] Step 401, obtaining a database calling component, wherein the database calling component is developed according to the request method and request parameters of the data in the preset database, and the request method and request parameters of the data in the preset database are obtained from the logic code.
[0056] Step 402: deploy the above database call component according to the deployment method of the microservice component.
[0057] Specifically, the above-mentioned database call component can be deployed according to the deployment method of the microservice component by: making an image file corresponding to the above-mentioned database call component, and pushing the above-mentioned image file to a registration (registry) image library; then modifying the configuration file of the above-mentioned microservice architecture according to the above-mentioned database call component and the image file corresponding to the above-mentioned database call component.
[0058] Among them, the configuration file of the above-mentioned microservice architecture can be a YAML file. YAML is a recursive abbreviation of "YAML Ain't a Markup Language". YAML is an intuitive data serialization format that can be recognized by computers. It is a programming language that is highly readable and easy for humans to read, easy to interact with scripting languages, and is used to express data sequences.
[0059] For example, in a microservice architecture based on spring cloud, you can configure various Eureka dependency packages in the root configuration file pom.xml of the developed microservice component, and configure the access address of Eureka in the configuration file applcation.yml of the root application. The access address of Eureka is the server address of Eureka. When all the configuration information is configured, compile the developed microservice component and upload it to the microservice component server. After the microservice component server obtains the microservice component, it makes relevant images, modifies YAML files, etc. Finally, use the relevant command line to start the above microservice component. Since the access address of Eureka has been configured in the configuration file, after starting the microservice component, the service name and access address of the above microservice component will be registered in the Eureka server.
[0060] Thus, this application Figure 3 In the illustrated embodiment, step 304 may be: obtaining the access address of the service discovery component from the configuration file of the microservice architecture, and registering the service name and access address of the database call component in the service discovery component according to the access address of the service discovery component.
[0061] After registration is completed, the database call component is in a public state. When needed, the service call component can obtain the access address of the database call component from the service discovery component according to the service name of the database call component, and then call the database call component. The service call component here includes the microservice component that needs to call the database call component in the microservice architecture.
[0062] Figure 5 This is a schematic diagram of the structure of an embodiment of the database calling device of the present application. The database calling device in this embodiment can be set in the service calling component to implement the present application. Figure 1 and Figure 2 The database calling method provided in the illustrated embodiment. The service calling component here includes a microservice component in the microservice architecture that needs to call a database calling component.
[0063] like Figure 5 As shown, the above-mentioned database calling device may include: an acquisition module 51 and a calling module 52;
[0064] The acquisition module 51 is used to obtain the service name of the database call component in the microservice architecture, where the database call component is a microservice component pre-set in the microservice architecture, and is used to call the data service of a preset database; and according to the service name of the database call component, obtain the access address of the database call component from the service discovery component of the microservice architecture; wherein the preset database can be a basic database or a database in other forms, and this embodiment does not limit the preset database.
[0065] The service name of the database calling component may be an HTTP service name, and the acquisition module 51 may obtain the access address of the database calling component from the service discovery component of the microservice architecture through the HTTP service name.
[0066] The service discovery component can be implemented using Eureka, which is a service discovery framework developed by Netflix. It is a REST-based service that mainly registers microservice components. After the microservice component is registered on Eureka, the registered microservice component can be found through Eureka.
[0067] Specifically, when the acquisition module 51 uses the HTTP service name to obtain the access address of the database calling component from the service discovery component, the service discovery component will find the access address corresponding to the HTTP service name from the service registration list according to the HTTP service name.
[0068] The calling module 52 is used to run the above database calling component according to the access address obtained by the obtaining module 51 to call the data service of the above preset database.
[0069] Specifically, when the calling module 52 runs the above database calling component according to the above access address, the calling module 52 also needs to pass in relevant parameters required for running the above database calling component, which will not be repeated here.
[0070] In this embodiment, the calling module 52 is specifically used to configure the access address into the request method for running the database calling component, and execute the request method to call the data service of the preset database.
[0071] In specific implementation, when configuring the access address into the request method, the calling module 52 may also configure the relevant parameters required to run the database calling component into the request method. The calling module 52 may use the Socket protocol to execute the request method. When using the Socket protocol to execute the request method, the HTTP protocol may be used to complete the call to the data service of the preset database.
[0072] In the above-mentioned database calling device, after the acquisition module 51 obtains the service name of the database calling component in the microservice architecture, it obtains the access address of the above-mentioned database calling component from the service discovery component of the above-mentioned microservice architecture according to the service name of the above-mentioned database calling component; then the calling module 52 runs the above-mentioned database calling component according to the above-mentioned access address to call the data service of the above-mentioned preset database. Among them, the above-mentioned database calling component is a microservice component pre-set in the microservice architecture, and the above-mentioned database calling component is used to call the data service of the preset database, so that the data service of the preset database can be called by the database calling component set in the microservice architecture, avoiding the component bloat problem caused by integrating multiple business functions in the same microservice component, reducing the coupling between microservice components, and improving the maintainability of microservice components.
[0073] Figure 6 This is a structural diagram of another embodiment of the database calling device of the present application. The database calling device in this embodiment can be set in the microservice component server to implement the present application. Figure 3 and Figure 4 The illustrated embodiment provides a method for calling a database.
[0074] like Figure 6 As shown, the above-mentioned database calling device may include: an acquisition module 61, an extraction module 62, a deployment module 63 and a registration module 64;
[0075] An acquisition module 61 is used to acquire a microservice component that needs to call a preset database in a microservice architecture;
[0076] The extraction module 62 is used to extract the logic code for calling the data service of the preset database from the microservice component that needs to call the preset database obtained by the acquisition module 61;
[0077] A deployment module 63, used to deploy corresponding database call components according to the logic code extracted by the extraction module 62;
[0078] In this embodiment, the deployment module 63 is specifically used to obtain a database call component and deploy the above-mentioned database call component according to the deployment method of the microservice component; the above-mentioned database call component is developed according to the request method and request parameters of the data in the preset database, and the request method and request parameters of the data in the preset database are obtained from the above-mentioned logic code.
[0079] In the specific implementation, the deployment module 63 is specifically used to create an image file corresponding to the above-mentioned database call component, push the above-mentioned image file to the registered image library, and modify the configuration file of the above-mentioned microservice architecture according to the above-mentioned database call component and the image file corresponding to the above-mentioned database call component.
[0080] Among them, the configuration file of the above-mentioned microservice architecture can be a YAML file. YAML is an intuitive data serialization format that can be recognized by computers. It is a programming language that is highly readable and easy for humans to read, easy to interact with scripting languages, and is used to express data sequences.
[0081] The registration module 64 is used to register the service name and access address of the database call component deployed by the deployment module 63 into the service discovery component of the above-mentioned microservice architecture, so that the service call component can obtain the access address of the above-mentioned database call component from the above-mentioned service discovery component according to the service name of the above-mentioned database call component, and run the above-mentioned database call component according to the above-mentioned access address to call the data service of the above-mentioned preset database.
[0082] For example, in a microservice architecture based on spring cloud, various dependency packages of Eureka can be configured in the root configuration file pom.xml of the developed microservice component, and the access address of Eureka can be configured in the configuration file applcation.yml of the root application. The access address of Eureka is the server address of Eureka. When all configuration information is configured, the developed microservice component is compiled and uploaded to the microservice component server. After obtaining the microservice component, the deployment module 63 makes relevant images, modifies YAML files, etc., and finally uses the relevant command line to start the above microservice component. Since the access address of Eureka has been configured in the configuration file, after starting the microservice component, the service name and access address of the above microservice component will be registered in the Eureka server.
[0083] In this way, the registration module 64 is specifically used to obtain the access address of the above-mentioned service discovery component from the configuration file of the above-mentioned microservice architecture; according to the access address of the above-mentioned service discovery component, the service name and access address of the above-mentioned database call component are registered in the above-mentioned service discovery component.
[0084] After registration is completed, the database call component is in a public state. When needed, the service call component can obtain the access address of the database call component from the service discovery component according to the service name of the database call component, and then call the database call component. The service call component here includes the microservice component that needs to call the database call component in the microservice architecture.
[0085] In this embodiment, the microservice components are split into microservice components of smaller granularity, and the deployment module 63 deploys a database call component in the microservice architecture, which is specifically responsible for calling the preset database, avoiding the component bloat problem caused by integrating multiple business functions into the same microservice component, reducing the coupling between microservice components, and making the business function of each microservice component clearer and easier to maintain.
[0086] Figure 7 This is a schematic diagram of the structure of an embodiment of a computer device of the present application. The computer device may include a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the present application can be implemented. Figure 1 and Figure 2 The illustrated embodiment provides a method for calling a database.
[0087] In this embodiment, a service calling component may be provided on the computer device, and this embodiment does not limit the specific form of the computer device.
[0088] Figure 7 A block diagram of an exemplary computer device suitable for implementing embodiments of the present application is shown. Figure 7 The computer device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0089] like Figure 7 As shown, the computer device is in the form of a general-purpose computing device. The components of the computer device may include, but are not limited to: one or more processors 410, memory 430, and a communication bus 440 connecting different system components (including memory 430 and processing unit 410).
[0090] The communication bus 440 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnection (PCI) bus.
[0091] Computer devices typically include a variety of computer system readable media. These media can be any available media that can be accessed by the computer device, including volatile and non-volatile media, removable and non-removable media.
[0092] The memory 430 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The computer device may further include other removable / non-removable, volatile / non-volatile computer system storage media. Figure 7Not shown, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., a compact disc read only memory (CD-ROM), a digital versatile disc read only memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to the communication bus 440 via one or more data medium interfaces. The memory 430 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.
[0093] A program / utility having a set (at least one) of program modules may be stored in memory 430, such program modules including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules typically perform the functions and / or methods of the embodiments described herein.
[0094] The computer device may also communicate with one or more external devices (e.g., keyboard, pointing device, display, etc.), one or more devices that enable a user to interact with the computer device, and / or any device that enables the computer device to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed via communication interface 420. In addition, the computer device may also communicate with a network adapter ( Figure 7 The network adapter can communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN) and / or a public network, such as the Internet) through the communication bus 440. It should be understood that although Figure 7 Not shown, other hardware and / or software modules may be used in conjunction with the computer device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Arrays of Independent Drives; hereinafter referred to as: RAID) systems, tape drives, and data backup storage systems.
[0095] The processor 410 executes various functional applications and data processing by running the programs stored in the memory 430, such as implementing the present application Figure 1 and Figure 2 The illustrated embodiment provides a method for calling a database.
[0096] The embodiment of the present application further provides a computer device, which may include a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the present application can be implemented. Figure 3 and Figure 4 The illustrated embodiment provides a method for calling a database.
[0097] In this embodiment, the above-mentioned computer device may be a microservice component server, and this embodiment does not limit the specific form of the above-mentioned computer device.
[0098] The structure of the above-mentioned computer device can be adopted Figure 7 The structure shown will not be described in detail here.
[0099] The present application also provides a non-temporary computer-readable storage medium having a computer program stored thereon, which can implement the present application when the computer program is executed by a processor. Figure 1 and Figure 2 The illustrated embodiment provides a method for calling a database.
[0100] The present application also provides a non-temporary computer-readable storage medium having a computer program stored thereon, which can implement the present application when the computer program is executed by a processor. Figure 3 and Figure 4 The illustrated embodiment provides a method for calling a database.
[0101] The above-mentioned non-temporary computer-readable storage medium can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (Read Only Memory; hereinafter referred to as: ROM), an erasable programmable read-only memory (ErasableProgrammable Read Only Memory; hereinafter referred to as: EPROM) or flash memory, optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0102] Computer-readable signal media may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0103] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0104] The computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (Local Area Network; hereinafter referred to as: LAN) or a wide area network (Wide Area Network; hereinafter referred to as: WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0105] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0106] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0107] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0108] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0109] It should be noted that the terminals involved in the embodiments of the present application may include but are not limited to personal computers (Personal Computer; hereinafter referred to as: PC), personal digital assistants (Personal Digital Assistant; hereinafter referred to as: PDA), wireless handheld devices, tablet computers (Tablet Computer), mobile phones, MP3 players, MP4 players, etc.
[0110] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0111] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0112] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (Processor) to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as: ROM), random access memory (Random Access Memory; hereinafter referred to as: RAM), disk or optical disk and other media that can store program codes.
[0113] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for calling a database, characterized in that: include: Get the microservice components that need to call the preset database in the microservice architecture; Extracting logic code for calling a data service function of the preset database from the microservice component that needs to call the preset database; Deploy the corresponding database call components according to the extracted logic code; Register the service name and access address of the deployed database call component in the service discovery component of the microservice architecture; The service calling component obtains the access address of the database calling component from the service discovery component according to the service name of the database calling component, and the service calling component runs the database calling component according to the access address to call the data service of the preset database; The deployment of the corresponding database call component according to the extracted logic code includes: Acquire a database calling component, wherein the database calling component is developed according to a request method and request parameters for data in the preset database, and the request method and request parameters for data in the preset database are acquired from the logic code; Deploy the database call component according to the deployment mode of the microservice component; The step of deploying the database call component according to the deployment mode of the microservice component includes: Creating a mirror file corresponding to the database calling component; Push the image file to the registered image library; The configuration file of the microservice architecture is modified according to the database calling component and the image file corresponding to the database calling component.
2. The method according to claim 1, characterized in that The step of registering the service name and access address of the deployed database call component into the service discovery component of the microservice architecture includes: Obtaining the access address of the service discovery component from the configuration file of the microservice architecture; According to the access address of the service discovery component, the service name and access address of the database calling component are registered in the service discovery component.
3. The method according to claim 1, characterized in that The service calling component runs the database calling component according to the access address to call the data service of the preset database, including: configuring the access address into a request method for running the database calling component; The request method is executed to call the data service of the preset database.
4. A database calling device, arranged in a microservice component server, characterized in that: The database calling device comprises: The acquisition module is used to obtain the microservice components that need to call the preset database in the microservice architecture; An extraction module, used to extract the logic code for calling the data service function of the preset database from the microservice component that needs to call the preset database obtained by the acquisition module; A deployment module is used to deploy the corresponding database call component according to the logic code extracted by the extraction module, which specifically includes: obtaining a database call component, the database call component is developed according to the request method and request parameters of the data in the preset database, and the request method and request parameters of the data in the preset database are obtained from the logic code; deploying the database call component according to the deployment method of the microservice component; the deployment of the database call component according to the deployment method of the microservice component includes: making an image file corresponding to the database call component; pushing the image file to a registered image library; modifying the configuration file of the microservice architecture according to the database call component and the image file corresponding to the database call component; A registration module, used to register the service name and access address of the database call component deployed by the deployment module into the service discovery component of the microservice architecture; The service calling component obtains the access address of the database calling component from the service discovery component according to the service name of the database calling component, and the service calling component runs the database calling component according to the access address to call the data service of the preset database.
5. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented.
