CN110602198B - Client network request link configuration method and system - Google Patents
Client network request link configuration method and system Download PDFInfo
- Publication number
- CN110602198B CN110602198B CN201910847317.1A CN201910847317A CN110602198B CN 110602198 B CN110602198 B CN 110602198B CN 201910847317 A CN201910847317 A CN 201910847317A CN 110602198 B CN110602198 B CN 110602198B
- Authority
- CN
- China
- Prior art keywords
- environment
- identifier
- configuration
- configuration item
- network request
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/08—Configuration management of networks or network elements
- H04L41/0803—Configuration setting
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention discloses a client network request link configuration method, which comprises the following steps: setting a unique environment name for each environment; setting a first identifier for each general configuration item which is irrelevant to the environment, and setting a second identifier for each environment configuration item under each environment; creating a configuration item acquisition interface, receiving an input environment name and a retrieval identifier, calling the configuration item acquisition interface to inquire whether a second identifier which is the same as the retrieval identifier exists in a corresponding environment, if so, returning a corresponding environment configuration item, and if not, returning a general configuration item which is the same as the first identifier of the retrieval identifier. The invention realizes the purpose of managing a plurality of environments by the same configuration file by adjusting the format of the configuration file, and has clear configuration process and good maintainability; in addition, a configuration item acquisition interface irrelevant to the environment is created, and a user only needs to call the configuration item acquisition interface to acquire required configuration item information without concerning the environment information, so that great development convenience conditions are provided.
Description
Technical Field
The invention relates to the technical field of configuration item management, in particular to a client network request link configuration method and a client network request link configuration system.
Background
In a test and development environment, network request links correspond to different values, and the link values are acquired according to different environments in development. There are two problems that exist today: first, if many places need to be acquired, the code repeatability is high; second, if there are multiple test environments, the number of judgment statements for obtaining a link value is also increased, resulting in poor code maintainability at the client.
In order to solve the foregoing problems, some technicians propose that multiple configuration files may be created according to different environments, but if a certain configuration item is irrelevant to the environment, all configuration files need to be configured with the same configuration item information, the configuration process is complex, and too many configuration files easily cause maintenance difficulty.
Disclosure of Invention
The invention aims to provide a client network request link configuration method and a system, which divide a configuration file into two major items, namely Base and Environment, by adjusting the format of the configuration file, wherein the former mainly configures general configuration items irrelevant to the Environment, and the latter mainly configures configuration items of the current specific Environment, so that the aim of managing a plurality of environments by the same configuration file is fulfilled, the configuration process is clear, and the maintainability is good; in addition, a configuration item acquisition interface irrelevant to the environment is created, and a user only needs to call the configuration item acquisition interface to acquire required configuration item information without concerning the environment information, so that great development convenience conditions are provided.
To achieve the above object, with reference to fig. 1, the present invention provides a method for configuring a client network request link, the method comprising:
setting a unique environment name for each environment;
setting a first identifier for each general configuration item irrelevant to the environment, and setting a second identifier for each environment configuration item under each environment, wherein the first identifiers among the general configuration items irrelevant to the environment are not repeated, and the second identifiers of the environment configuration items under each environment are not repeated;
creating a configuration item acquisition interface, receiving an input environment name and a retrieval identifier, calling the configuration item acquisition interface to inquire whether a second identifier which is the same as the retrieval identifier exists in a corresponding environment, if so, returning a corresponding environment configuration item, and if not, returning a general configuration item which is the same as the first identifier of the retrieval identifier.
In a further embodiment, the method further comprises:
setting unique host address information for each environment;
and if the second identifier which is the same as the retrieval identifier does not exist in the corresponding environment, inquiring whether the first identifier which is the same as the retrieval identifier exists, if so, returning the corresponding general configuration item, and otherwise, returning host address information of the configuration file in the current environment.
In a further embodiment, the method further comprises:
judging the type of the called component of the configuration item acquisition interface, and acquiring a corresponding address type according to the type of the component;
the component type comprises a host address acquisition component and a path address acquisition component, and the address type comprises a host address and a path address.
In a further embodiment, the first identity and the second identity correspond to host address information and/or psth address information.
Based on the foregoing method, the present invention further provides a client network request link configuration system, including:
the environment management module is used for creating and deleting environments and managing the environment name of each environment;
the configuration item management module is used for creating, deleting configuration items and managing unique identifiers of each configuration item, wherein the configuration items comprise general configuration items irrelevant to environments and environment configuration items corresponding to each environment, the unique identifiers of the general configuration items are defined as first identifiers, the unique identifiers of the environment configuration items are defined as second identifiers, the first identifiers are not repeated, and the second identifiers of the environment configuration items in the same environment are not repeated;
and the configuration item acquisition interface is used for receiving the input environment name and the retrieval identifier, inquiring whether a second identifier which is the same as the retrieval identifier exists in the corresponding environment, if so, returning the corresponding environment configuration item, and if not, returning the general configuration item which is the same as the first identifier of the retrieval identifier.
In a further embodiment, the environment management module is further configured to manage host address information corresponding to each environment;
the configuration item acquisition interface is used for receiving an input environment name and a retrieval identifier, inquiring whether a second identifier which is the same as the retrieval identifier exists in a corresponding environment, if so, returning a corresponding environment configuration item, and if not, inquiring whether a first identifier which is the same as the retrieval identifier exists:
if yes, returning the corresponding general configuration item, otherwise, returning host address information of the configuration file in the current environment.
In a further embodiment, any one or two of SERVER _ HOST _ URL and SERVER _ PATH _ URL are recorded in the unique identifier;
the SERVER _ HOST _ URL configures HOST address information of a network request link, and the SERVER _ PATH _ URL configures PATH address information of the network request link.
In a further embodiment, the configuration item acquisition interface includes the following functional components:
1) the void setEnvironmentName component is used for setting an environment name after the program is started;
2) a string getServerHostWithIdentity component for obtaining the host address of the network request link according to the input unique identifier;
3) a string getServerPathWithIdentity component for obtaining the path address of the network request link according to the input unique identifier
Compared with the prior art, the technical proposal of the invention has the obvious beneficial effects that,
(1) the configuration file is divided into two main items, namely Base and Environment, by adjusting the format of the configuration file, the former mainly configures general configuration items irrelevant to the Environment, and the latter mainly configures configuration items of the current specific Environment, so that the aim of managing a plurality of environments through the same configuration file is fulfilled, the configuration process is clear, and the maintainability is good.
(2) And a configuration item acquisition interface irrelevant to the environment is created, and a user only needs to call the configuration item acquisition interface to acquire the required configuration item information without concerning the environment information, so that great development convenience conditions are provided.
(3) The method solves the problems that the existing code has high repeatability and the client code has poor maintainability due to the increase of judgment sentences for acquiring the link values in a plurality of test environments.
(4) The method provided by the invention is not limited to the configuration of the network request link, and is in fact suitable for any configuration of the client, wide in applicability and easy to expand.
It should be understood that all combinations of the foregoing concepts and additional concepts described in greater detail below can be considered as part of the inventive subject matter of this disclosure unless such concepts are mutually inconsistent. In addition, all combinations of claimed subject matter are considered a part of the presently disclosed subject matter.
The foregoing and other aspects, embodiments and features of the present teachings can be more fully understood from the following description taken in conjunction with the accompanying drawings. Additional aspects of the present invention, such as features and/or advantages of exemplary embodiments, will be apparent from the description which follows, or may be learned by practice of specific embodiments in accordance with the teachings of the present invention.
Drawings
The drawings are not intended to be drawn to scale. In the drawings, each identical or nearly identical component that is illustrated in various figures may be represented by a like numeral. For purposes of clarity, not every component may be labeled in every drawing. Embodiments of various aspects of the present invention will now be described, by way of example, with reference to the accompanying drawings, in which:
fig. 1 is a flow chart of a client network request link configuration method of the present invention.
FIG. 2 is a method flow diagram of one example of the present invention.
Fig. 3 is a method flow diagram of another example of the invention.
Detailed Description
In order to better understand the technical content of the present invention, specific embodiments are described below with reference to the accompanying drawings.
With reference to fig. 1, the present invention provides a method for configuring a client network request link, where the method includes:
s1: a unique environment name is set for each environment.
S2: setting a first identifier for each general configuration item irrelevant to the environment, and setting a second identifier for each environment configuration item under each environment, wherein the first identifiers among the general configuration items irrelevant to the environment are not repeated, and the second identifiers of the environment configuration items under each environment are not repeated.
S3: creating a configuration item acquisition interface, receiving an input environment name and a retrieval identifier, calling the configuration item acquisition interface to inquire whether a second identifier which is the same as the retrieval identifier exists in a corresponding environment, if so, returning a corresponding environment configuration item, and if not, returning a general configuration item which is the same as the first identifier of the retrieval identifier.
Based on the foregoing method, the present invention further provides a client network request link configuration system, including:
(1) and the environment management module is used for creating and deleting the environment and managing the environment name of each environment.
(2) The configuration item management module is used for creating, deleting configuration items and managing unique identifications of each configuration item, wherein the configuration items comprise general configuration items irrelevant to environments and environment configuration items corresponding to each environment, the unique identifications of the general configuration items are defined as first identifications, the unique identifications of the environment configuration items are defined as second identifications, the first identifications are not repeated, and the second identifications of the environment configuration items in the same environment are not repeated.
(3) And the configuration item acquisition interface is used for receiving the input environment name and the retrieval identifier, inquiring whether a second identifier which is the same as the retrieval identifier exists in the corresponding environment, if so, returning the corresponding environment configuration item, and if not, returning the general configuration item which is the same as the first identifier of the retrieval identifier.
The method proposed by the present invention is explained in detail below from two aspects with reference to specific examples.
One, only one configuration item file is created
One and the same item can be configured and can be configured separately according to different environments.
Assume that the following three environments exist in a scene: develop, Sit, Product.
The configuration file format is as follows:
as can be seen from the aforementioned configuration file, the configuration file is divided into two major items: the system comprises Base and Environment, wherein the Base mainly configures general configuration items which are irrelevant to the Environment, the Environment mainly configures configuration items of the current specific Environment, and the first item under the Environment is a unique identifier (Environment name) of the Environment and can be added or deleted. Each configuration item has a unique identifier, such as Advertisement1, Advertisement2, development, site, etc., and the unique identifier of the configuration item has the following characteristics:
1) there was no duplication under Base.
2) The method can not be repeated in a specific Environment of Environment, but the identifiers in different environments can be repeated, so that the same identifier can be repeatedly utilized, the total number of the identifiers is reduced, and the method is easy to maintain and manage.
3) Any one or two items of SERVER _ HOST _ URL and SERVER _ PATH _ URL may be recorded in the identifier. The SERVER _ HOST _ URL configures HOST address information of a network request link, and the SERVER _ PATH _ URL configures PATH address information of the network request link. As in the "development" context, the identifier "Advertisement1" corresponds to "SERVER _ HOST _ URL", while in the "Base" identifier "Advertisement2" corresponds to "SERVER _ HOST _ URL", "SERVER _ PATH _ URL", and so forth.
In some examples, the method further comprises:
setting unique host address information for each environment; and if the second identifier which is the same as the retrieval identifier does not exist in the corresponding environment, inquiring whether the first identifier which is the same as the retrieval identifier exists, if so, returning the corresponding general configuration item, and otherwise, returning host address information of the configuration file in the current environment.
As in the foregoing configuration file, in the "devilop" environment, the "SERVER _ HOST _ URL" is set to https:// dev.com.cn/, in the "site" environment, the "SERVER _ HOST _ URL" is set to https:// site.com.cn/, and in the "Product" environment, the "SERVER _ HOST _ URL" is set to https:// prd.com.cn/.
And when the second identifier and the first identifier corresponding to the retrieval identifier are not inquired, returning a host address in a preset corresponding environment, such as https:// sit.com.cn/, https:// prd.com.cn/, of a Product environment and the like.
Two, creation and environment independent configuration item acquisition interface
The development only needs to call the configuration item acquisition interface to acquire the configuration item information without concerning the environment.
The configuration item acquisition interface is used as a uniform interface irrelevant to the environment, so that the daily development work of developers is greatly facilitated, and the developers can quickly acquire corresponding configuration item information only by inputting the required environment name and the identification information corresponding to the configuration item.
Fig. 2 and fig. 3 are two configuration item acquisition examples, respectively, and the functions of part of the components included in the configuration item acquisition interface are as follows:
1)void setEnvironmentName(string name)
after the program is started, an Environment name is to be set, and the incoming name is a certain identifier (e.g., development, site, Product in the foregoing example) corresponding to the first item under the Environment in the configuration file.
2)string getServerHostWithIdentity(string identity)
And acquiring the host address of the network request link according to the input unique identifier.
3)string getServerPathWithIdentity(string identity)
And acquiring the path address of the network request link according to the input unique identifier.
In fig. 2, if the input environment name is "development", the input search identifier is "Advertisement1", and the search identifier is found to correspond to "SERVER _ HOST _ URL" as "https:// Advertisement dev. com.cn/" by searching the configuration file, and "https:// Advertisement dev. com.cn/" is returned.
In some examples, the method further comprises:
and judging the type of the called component of the configuration item acquisition interface, and acquiring the corresponding address type according to the type of the component.
The component type comprises a host address acquisition component and a path address acquisition component, and the address type comprises a host address and a path address.
If the input environment name is ' development op ', the input retrieval identification is ' Advertisement2 ', the retrieval identification is found to be the same as the second identification of any configuration item under the environment through retrieving the configuration file, whether the same first identification exists under the base is continuously inquired, the identification ' Advertisement2 ' is found to correspond to two addresses under the base condition, at the moment, the corresponding address can be returned according to the called component category, for example, if the adopted component category is ' StringgetServerHostWithput ', a host address is returned, namely ' https:// Advertisement base.
As shown in fig. 3, the adopted component is "string getServerPathWithIdentity", if the input environment name is "site", the input retrieval identifier is "Advertisement4", and the path address of "Advertisement/getAdvertisement4-2" is returned by retrieving the configuration file; correspondingly, if the input environment name is "development" or "Product", because the configuration item corresponding to "Advertisement4" is not set in the two environments, the query is continued to determine whether the same first identifier exists in the base, and it is found that under the base condition, the identifier "Advertisement4" corresponds to "Advertisement/getAdvertisement4-1", and the corresponding value "Advertisement/getAdvertisement4-1" is returned.
As for the calling modes of the two components, the user can select any one or two of the calling modes in sequence according to actual needs.
It should be understood that the method mentioned in the present invention is not limited to the configuration of the network request link, and in fact, the method is applicable to any configuration of the client, and is wide in applicability and easy to expand. The rules for obtaining configuration items are as follows:
1) firstly, judging whether the corresponding unique identifier exists in the current environment or not, and returning the unique identifier.
2) And if not, acquiring a value corresponding to the unique identifier under the Base.
In this disclosure, aspects of the present invention are described with reference to the accompanying drawings, in which a number of illustrative embodiments are shown. Embodiments of the present disclosure are not necessarily defined to include all aspects of the invention. It should be appreciated that the various concepts and embodiments described above, as well as those described in greater detail below, may be implemented in any of numerous ways, as the disclosed concepts and embodiments are not limited to any one implementation. In addition, some aspects of the present disclosure may be used alone, or in any suitable combination with other aspects of the present disclosure.
Although the present invention has been described with reference to the preferred embodiments, it is not intended to be limited thereto. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the invention. Therefore, the protection scope of the present invention should be determined by the appended claims.
Claims (8)
1. A client network request link configuration method, the method comprising:
setting a unique environment name for each environment;
setting a first identifier for each general configuration item irrelevant to the environment, and setting a second identifier for each environment configuration item under each environment, wherein the first identifiers among the general configuration items irrelevant to the environment are not repeated, and the second identifiers of the environment configuration items under each environment are not repeated;
creating a configuration item acquisition interface, receiving an input environment name and a retrieval identifier, calling the configuration item acquisition interface to inquire whether a second identifier which is the same as the retrieval identifier exists in a corresponding environment, if so, returning a corresponding environment configuration item, and if not, returning a general configuration item which is the same as the first identifier of the retrieval identifier.
2. The client network request link configuration method of claim 1, further comprising:
setting unique host address information for each environment;
and if the second identifier which is the same as the retrieval identifier does not exist in the corresponding environment, inquiring whether the first identifier which is the same as the retrieval identifier exists, if so, returning the corresponding general configuration item, and otherwise, returning host address information of the configuration file in the current environment.
3. The client network request link configuration method according to claim 1 or 2, wherein the method further comprises:
judging the type of the called component of the configuration item acquisition interface, and acquiring a corresponding address type according to the type of the component;
the component type comprises a host address acquisition component and a path address acquisition component, and the address type comprises a host address and a path address.
4. The client network request link configuration method of claim 1, wherein the first identifier and the second identifier correspond to host address information and/or path address information.
5. A client network request link configuration system, the system comprising:
the environment management module is used for creating and deleting environments and managing the environment name of each environment;
the configuration item management module is used for creating, deleting configuration items and managing unique identifiers of each configuration item, wherein the configuration items comprise general configuration items irrelevant to environments and environment configuration items corresponding to each environment, the unique identifiers of the general configuration items are defined as first identifiers, the unique identifiers of the environment configuration items are defined as second identifiers, the first identifiers are not repeated, and the second identifiers of the environment configuration items in the same environment are not repeated;
and the configuration item acquisition interface is used for receiving the input environment name and the retrieval identifier, inquiring whether a second identifier which is the same as the retrieval identifier exists in the corresponding environment, if so, returning the corresponding environment configuration item, and if not, returning the general configuration item which is the same as the first identifier of the retrieval identifier.
6. The client network request link configuration system of claim 5, wherein the environment management module is further configured to manage host address information corresponding to each environment;
the configuration item acquisition interface is used for receiving an input environment name and a retrieval identifier, inquiring whether a second identifier which is the same as the retrieval identifier exists in a corresponding environment, if so, returning a corresponding environment configuration item, and if not, inquiring whether a first identifier which is the same as the retrieval identifier exists:
if yes, returning the corresponding general configuration item, otherwise, returning host address information of the configuration file in the current environment.
7. The client network request link configuration system according to claim 5, wherein any one or two of SERVER _ HOST _ URL, SERVER _ PATH _ URL are recorded in the unique identifier;
the SERVER _ HOST _ URL configures HOST address information of a network request link, and the SERVER _ PATH _ URL configures PATH address information of the network request link.
8. The client network request link configuration system of claim 5, wherein the configuration item acquisition interface comprises the following functional components:
the void setEnvironmentName component is used for setting an environment name after the program is started;
a string getServerHostWithIdentity component for obtaining the host address of the network request link according to the input unique identifier;
and the string getServerPathWithIdentity component is used for acquiring the path address of the network request link according to the input unique identifier.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910847317.1A CN110602198B (en) | 2019-09-09 | 2019-09-09 | Client network request link configuration method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910847317.1A CN110602198B (en) | 2019-09-09 | 2019-09-09 | Client network request link configuration method and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110602198A CN110602198A (en) | 2019-12-20 |
CN110602198B true CN110602198B (en) | 2021-11-30 |
Family
ID=68858132
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910847317.1A Active CN110602198B (en) | 2019-09-09 | 2019-09-09 | Client network request link configuration method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110602198B (en) |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5634098A (en) * | 1995-02-01 | 1997-05-27 | Sun Microsystems, Inc. | Method and apparatus for environment-variable driven software testing |
CN100401809C (en) * | 2004-11-17 | 2008-07-09 | 华为技术有限公司 | Interface parameter configuration of mobile telecommunication system |
US8549144B2 (en) * | 2007-08-31 | 2013-10-01 | International Business Machines Corporation | Common configuration framework for applications to configure database objects and resources |
CN102455915A (en) * | 2010-10-18 | 2012-05-16 | 卓望数码技术(深圳)有限公司 | Method for automatically configuring distributed system, and server |
CN102638508A (en) * | 2011-11-03 | 2012-08-15 | 李宗诚 | Internet holo-synergetic system configuration environment design |
CN108536489B (en) * | 2018-04-23 | 2022-03-25 | 腾讯科技(深圳)有限公司 | Method, apparatus, and computer-readable storage medium for matching resource environments |
-
2019
- 2019-09-09 CN CN201910847317.1A patent/CN110602198B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN110602198A (en) | 2019-12-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101957857B (en) | Automatic information push method and server | |
CN104796326B (en) | A kind of group creating method and device of enterprise IM | |
TWI740029B (en) | Distributed search and index updating method, system, server and computer equipment | |
CN100571423C (en) | Group sending system and method based on search engine | |
CN109213758B (en) | Data access method, device, equipment and computer readable storage medium | |
CN107846483A (en) | A kind of domain name analytic method, system and server | |
CN109740129B (en) | Report generation method, device and equipment based on blockchain and readable storage medium | |
CN112788126A (en) | Resource downloading method, device, server and storage medium | |
CN107491463B (en) | Optimization method and system for data query | |
CN105471700B (en) | A kind of methods, devices and systems of Message Processing | |
CN101667932B (en) | Method of network element equipment log management and device | |
US20140156809A1 (en) | Data downloading method, terminal, server, and system | |
US11599396B2 (en) | Resegmenting chunks of data based on source type to facilitate load balancing | |
CN113157904A (en) | Sensitive word filtering method and system based on DFA algorithm | |
CN107545039B (en) | Keyword index acquisition method and device, computer equipment and storage medium | |
CN110602198B (en) | Client network request link configuration method and system | |
CN102546977A (en) | Method for processing calling information and processing system of method | |
CN113297274B (en) | Signing data query method and system | |
CN106649678B (en) | Data processing method and system | |
US10762238B2 (en) | Ascertaining network devices used with anonymous identifiers | |
CN107104889B (en) | Draft mail synchronization method, draft mail synchronization device and draft mail synchronization terminal based on IMAP protocol | |
CN102208085A (en) | Method for acquiring user favorite data based on agent system and data processing device | |
CN103856535B (en) | A kind of method and apparatus obtaining user data | |
CN105653540A (en) | Method and device for processing file attribute information | |
CN109104499B (en) | Session establishing method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP01 | Change in the name or title of a patent holder |
Address after: No.88, Huaihai Road, Qinhuai District, Nanjing, Jiangsu 210001 Patentee after: Nanyin Faba Consumer Finance Co.,Ltd. Address before: No.88, Huaihai Road, Qinhuai District, Nanjing, Jiangsu 210001 Patentee before: SUNING CONSUMER FINANCE Co.,Ltd. |
|
CP01 | Change in the name or title of a patent holder |