Disclosure of Invention
In view of the above, embodiments of the present invention provide a method and an apparatus for version update, which can avoid the technical defect that in the prior art, when a version is updated, a large number of logic codes in a server need to be traversed to obtain whether the version can be updated, so as to achieve the technical effect that the code logic is simpler and easy to maintain compared with the prior art.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method for version update, including:
Intercepting a request for updating an application version, wherein the request comprises a client version number for sending the request;
Determining a version number to be updated, which is matched with the version number of the client, by utilizing a mapping relation configured by a configuration center;
And updating the application to be updated according to the version number to be updated.
Optionally, before determining the version number to be updated matched with the client version number by using the mapping relation configured by the configuration center, the method includes:
configuring mapping relations between each version number to be updated and each client version number in a configuration center;
Or configuring mapping relations among the version numbers of the clients, the version numbers to be updated and the branch methods corresponding to the version numbers to be updated in the configuration center.
Optionally, updating the application to be updated according to the version number to be updated includes:
determining a parent class corresponding to the version number to be updated;
determining a subclass corresponding to the version number to be updated according to the parent class;
and updating the application to be updated by utilizing the basic method in the parent class and the branch method in the subclass.
Optionally, before determining the version number to be updated matched with the client version number by using the mapping relation configured by the configuration center, the method includes:
Establishing a parent class corresponding to each version number to be updated;
Writing basic methods corresponding to the version numbers to be updated in the parent class;
based on the parent class, respectively establishing subclasses corresponding to the version numbers to be updated;
respectively writing a branch method corresponding to each version number to be updated in each subclass;
and configuring the mapping relation between each version number to be updated and the branch method.
Optionally, updating the application to be updated according to the version number to be updated includes:
Determining the class corresponding to the version number to be updated;
Judging whether the class exists in the branch method corresponding to the version number to be updated;
if not, updating the application to be updated according to the basic method in the class;
And if so, updating the application to be updated according to the branching method corresponding to the version number to be updated.
Optionally, before determining the version number to be updated matched with the client version number by using the mapping relation configured by the configuration center, the method includes:
Establishing a class corresponding to each version number to be updated;
Respectively writing a branch method corresponding to each version number to be updated in the class;
Writing a base method in the class;
And configuring mapping relations among the version numbers to be updated, the branch methods and the basic methods.
According to still another aspect of an embodiment of the present invention, there is provided an apparatus for version update, including:
the system comprises a request interception module, a request updating module and a request updating module, wherein the request interception module is used for intercepting a request for updating an application version, and the request comprises a client version number for sending out the request;
the judging module is used for determining a version number to be updated, which is matched with the version number of the client, by utilizing the mapping relation configured by the configuration center;
and the updating module is used for updating the application to be updated according to the version number to be updated if the version number to be updated is the same.
Optionally, the system comprises a configuration module, which is used for determining the version number to be updated matched with the version number of the client before utilizing the mapping relation configured by the configuration center,
Configuring mapping relations between each version number to be updated and each client version number in a configuration center;
Or configuring mapping relations among the version numbers of the clients, the version numbers to be updated and the branch methods corresponding to the version numbers to be updated in the configuration center.
According to another aspect of an embodiment of the present invention, there is provided a version-update electronic device including:
One or more processors;
Storage means for storing one or more programs,
When the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the version updating method provided by the present invention.
According to a further aspect of an embodiment of the present invention, there is provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements the version update method provided by the present invention.
One embodiment of the above invention has the following advantages or benefits:
The technical means of configuring the version number to be updated corresponding to the version number of the client side in the configuration center avoids the technical defect that whether the version number can be updated or not can be obtained only by traversing a large number of logic codes in the server side when the version is updated in the prior art, and further achieves the technical effect that the code logic is simpler and is easy to maintain compared with the prior art.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of main flow of a version updating method according to an embodiment of the present invention, as shown in fig. 1, including:
s101, intercepting a request for updating an application version, wherein the request comprises a client version number for sending out the request;
Step S102, determining a version number to be updated, which is matched with the version number of the client, by using a mapping relation configured by a configuration center;
and step S103, updating the application to be updated according to the version number to be updated.
When the server updates the version of the application, the request sent by the application to be updated needs to be acquired first. The server updates the application of the server with the information contained in the request.
By the technical means of configuring the version number to be updated corresponding to the version number of the client in the configuration center, the technical defect that whether updating can be achieved or not only can be achieved by traversing a large number of logic codes in the server when the version is updated in the prior art is avoided, and further the technical effect that the code logic is simpler and easy to maintain compared with the prior art is achieved.
When the configuration center is determined to have the version number to be updated, which is matched with the version number of the client, a subsequent version updating operation can be performed.
In the application, the configuration center stores at least the mapping relation between the version number of the client and the version number to be updated. Mapping relations between version numbers to be updated and corresponding classes and methods in the classes can also be stored in the configuration center. In alternative embodiments of the present application, the configuration center may be replaced with a configuration file.
By setting the configuration center, the mapping relation is only required to be changed at the configuration center when the version to be updated needs to be maintained, so that the maintenance cost is reduced, the configuration center can be independently tested during testing, the technical defect that all codes of the version to be updated need to be tested in the prior art is avoided, and the aim of reducing the testing cost is fulfilled.
According to the application, through the steps S101-S103, the configuration center is used for determining the version number to be updated, which is matched with the version number of the client, and then the technical means of updating the application to be updated according to the version number to be updated is adopted, so that the technical defects that the logic is disordered and difficult to maintain due to a large number of branch sentences in the code for updating the application version of the client in the server in the prior art are overcome, the test cost is reduced, the maintenance cost is reduced, and the technical effect of improving the efficiency of updating the application version is achieved.
The embodiment of the application can hide calling details for the client when the code is updated, so that the client does not need to consider the problem of multiple versions when the version is updated, and the service logic of other versions can not be influenced when the service logic of a certain version to be updated is modified directly according to the version number to be updated determined in the configuration center, thereby achieving the technical effect of reducing the workload of testers.
Optionally, before determining the version number to be updated matched with the client version number by using the mapping relation configured by the configuration center, the method includes:
configuring mapping relations between each version number to be updated and each client version number in a configuration center;
Or configuring mapping relations among the version numbers of the clients, the version numbers to be updated and the branch methods corresponding to the version numbers to be updated in the configuration center.
The configuration center may be zookeeper, spring Cloud Eureka, consul, etc., which are not listed here.
When the configuration center adopts the zookeeper, real-time dynamic version control adjustment can be realized without restarting the server.
Optionally, updating the application to be updated according to the version number to be updated includes:
determining a parent class corresponding to the version number to be updated;
determining a subclass corresponding to the version number to be updated according to the parent class;
and updating the application to be updated by utilizing the basic method in the parent class and the branch method in the subclass.
Optionally, before determining the version number to be updated matched with the client version number by using the mapping relation configured by the configuration center, the method includes:
Establishing a parent class corresponding to each version number to be updated;
Writing basic methods corresponding to the version numbers to be updated in the parent class;
based on the parent class, respectively establishing subclasses corresponding to the version numbers to be updated;
respectively writing a branch method corresponding to each version number to be updated in each subclass;
and configuring the mapping relation between each version number to be updated and the branch method.
Specifically, the basic method can also be put into a parent class, and each method to be called by the version to be updated is put into a different subclass and covers the methods in the parent class. The configuration in the configuration center may be a mapping of client version numbers to corresponding subclasses.
In an alternative embodiment of the present application, each version to be updated corresponding to an application may be written in a parent class, in which a basic method and a branch method are defined, and in this example, the basic method refers to a method shared by each version to be updated, that is, the basic method needs to be invoked no matter any version to be updated is adopted. And updating the application to be updated by a preset method corresponding to the version number to be updated in the parent class.
In an alternative embodiment of the present application, updating the application to be updated according to the version number to be updated includes:
Determining the class corresponding to the version number to be updated;
Judging whether the class exists in the branch method corresponding to the version number to be updated;
if not, updating the application to be updated according to the basic method in the class;
And if so, updating the application to be updated according to the branching method corresponding to the version number to be updated.
Optionally, before determining the version number to be updated matched with the client version number by using the mapping relation configured by the configuration center, the method includes:
Establishing a class corresponding to each version number to be updated;
Respectively writing a branch method corresponding to each version number to be updated in the class;
Writing a base method in the class;
And configuring mapping relations among the version numbers to be updated, the branch methods and the basic methods.
By configuring technical means of methods corresponding to different version numbers to be updated in the class, the technical defect that when the requirement is changed, multi-branch codes are possibly involved in modification, and the error rate is high is overcome.
When updating the application to be updated, whether the application to be updated has a corresponding branching method or not can be judged according to the mapping relation, and then the application is updated according to the branching method.
In an alternative embodiment of the present application, different methods corresponding to the client may be set in one class, and when the application needs to be updated, the different methods corresponding to the client are called to the class, and then the application is updated.
Specifically, in one class, a method that needs to be invoked by different client versions, such as a1, a2, a3, is defined, and then an agent transparent to the client is set in the server. The agent firstly judges whether a method corresponding to the client exists in the configuration center, and if so, the method corresponding to the client is used for updating the application.
The pseudo code for the class is as follows:
based on the pseudo code of the class, the mapping relationship between the version number to be updated and the version number of the client configured in the configuration center may be:
The basic methods for updating the application version { "=android_3.0.1": branch method 1"," < android_3.0.1": branch method 2", "< ios_3.0.1": branch method 3"}
The mapping relation indicates that the client of android 3.0.1 calls the branch method 1, the client with version number smaller than android 3.0.1 calls the branch method 2, and the client with version number smaller than < ios_3.0.1 calls the branch method 3. And if the matched version is not available in the configuration center, calling a basic method.
The relationship between the configuration center and the version to be updated is further described in detail below in one embodiment.
Fig. 2 is a schematic diagram of a server for updating a client version.
As shown in fig. 2, the server has a server portal, which is configured to receive a request sent by the client to update a server version.
Setting a proxy transparent to the client in the server for judging whether a method corresponding to the client exists in the configuration center or not;
the server also comprises a configuration center, a basic method A, a branch method B, a branch method C and a branch method D.
Optionally, a mapping relation between the version number to be updated and the corresponding preset method is configured in the configuration center, then the corresponding preset method of the version number to be updated can be directly determined through the configuration center, and then the preset method is called to directly update the application.
The alternative embodiment of the application realizes the hiding of version calling details for a calling party (namely a client) through the technical means of dynamic proxy, so that service personnel do not need to excessively care about the problem of version branch control when developing programs, any if else branch statement does not need to be written in calling codes, and the technical defects that a large number of branch statements exist in codes for updating the application version of the client in a server in the prior art, logic is disordered and difficult to maintain are overcome.
The application achieves the method of flexibly calling different client versions through the form of the configuration center, reduces the test cost and the maintenance cost, reduces the complexity of modifying branches, and further achieves the technical effect of reducing the error rate.
The steps for version updating by the client are described in detail in one embodiment.
Fig. 3 is a flow diagram of a client for updating a client version.
Step S301, intercepting an update request by utilizing a section-oriented programming (AOP);
Step S302, receiving whether the configuration center zookeeper configures the mapping relation between each version number to be updated of the client and each client version number, if so, executing step S303, otherwise, executing step S305;
Step S303, accepting and judging whether the version number of the client has a corresponding version number to be updated, if so, executing step S304, otherwise, executing step S305;
step S304, updating the client according to the version number to be updated corresponding to the version number of the client;
Step S305, receiving information that cannot be updated to the client.
Fig. 4 is a schematic diagram of main modules of an apparatus 400 for version update according to an embodiment of the present invention, as shown in fig. 4, including:
a request interception module 401, configured to intercept a request for updating an application version, where the request includes a client version number for sending the request;
a determining module 402, configured to determine whether a version number to be updated that matches the version number of the client exists in the configuration center;
and the updating module 403 is configured to update the application to be updated according to the version number to be updated if yes.
Optionally, the system comprises a configuration module, which is used for determining the version number to be updated matched with the version number of the client before utilizing the mapping relation configured by the configuration center,
Configuring mapping relations between each version number to be updated and each client version number in a configuration center;
Or configuring mapping relations among the version numbers of the clients, the version numbers to be updated and the branch methods corresponding to the version numbers to be updated in the configuration center.
Optionally, updating the application to be updated according to the version number to be updated includes:
determining a parent class corresponding to the version number to be updated;
determining a subclass corresponding to the version number to be updated according to the parent class;
and updating the application to be updated by utilizing the basic method in the parent class and the branch method in the subclass.
Optionally, before determining the version number to be updated matched with the client version number by using the mapping relation configured by the configuration center, the method includes:
Establishing a parent class corresponding to each version number to be updated;
Writing basic methods corresponding to the version numbers to be updated in the parent class;
based on the parent class, respectively establishing subclasses corresponding to the version numbers to be updated;
respectively writing a branch method corresponding to each version number to be updated in each subclass;
and configuring the mapping relation between each version number to be updated and the branch method.
Optionally, updating the application to be updated according to the version number to be updated includes:
Determining the class corresponding to the version number to be updated;
Judging whether the class exists in the branch method corresponding to the version number to be updated;
if not, updating the application to be updated according to the basic method in the class;
And if so, updating the application to be updated according to the branching method corresponding to the version number to be updated.
Optionally, before determining the version number to be updated matched with the client version number by using the mapping relation configured by the configuration center, the method includes:
Establishing a class corresponding to each version number to be updated;
Respectively writing a branch method corresponding to each version number to be updated in the class;
Writing a base method in the class;
And configuring mapping relations among the version numbers to be updated, the branch methods and the basic methods.
Fig. 5 illustrates an exemplary system architecture 500 in which a version-up method or version-up apparatus of embodiments of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 is used as a medium to provide communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 505 via the network 504 using the terminal devices 501, 502, 503 to receive or send messages or the like. Various communication client applications may be installed on the terminal devices 501, 502, 503, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 501, 502, 503 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server (by way of example only) providing support for shopping-type websites browsed by users using the terminal devices 501, 502, 503. The background management server may analyze and process the received data such as the product information query request, and feedback the processing result (e.g., the target push information, the product information—only an example) to the terminal device.
It should be noted that, the version updating method provided in the embodiment of the present invention is generally executed by the server 505, and accordingly, the version updating device is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, there is illustrated a schematic diagram of a computer system 600 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 6 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Connected to the I/O interface 605 are an input section 606 including a keyboard, a mouse, and the like, an output section 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like, a storage section 608 including a hard disk, and the like, and a communication section 609 including a network interface card such as a LAN card, a modem, and the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 601.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of a computer-readable storage medium may include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. 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.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, a processor may be described as comprising a sending module, an obtaining module, a determining module and a first processing module. The names of these modules do not in some cases limit the module itself, and for example, the transmitting module may also be described as "a module that transmits a picture acquisition request to a connected server".
As a further aspect, the invention also provides a computer readable medium which may be comprised in the device described in the above embodiments or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include:
Intercepting a request for updating an application version, wherein the request comprises a client version number for sending the request;
Determining a version number to be updated, which is matched with the version number of the client, by utilizing a mapping relation configured by a configuration center;
And updating the application to be updated according to the version number to be updated.
According to the technical scheme provided by the embodiment of the invention, the following beneficial effects can be achieved:
The technical means of configuring the version number to be updated corresponding to the version number of the client side in the configuration center avoids the technical defect that whether the version number can be updated or not can be obtained only by traversing a large number of logic codes in the server side when the version is updated in the prior art, and further achieves the technical effect that the code logic is simpler and is easy to maintain compared with the prior art.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.