A method and device for establishing connection with dependent services
By obtaining dependent service information to generate connection tasks and reading parameters to establish connections, the problems of low efficiency and omission of dependent service connections in the existing technology are solved, and the connection results are quickly established and displayed, and the user experience is improved.
Patent Information
- Application Number
- CN202010603594.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-29
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2040-06-29
AI Technical Summary
In the prior art, by inputting parameters to target applications, establishing a dependent service connection is inefficient and easy to miss, resulting in long wait times and poor experiences.
By obtaining the dependency service information of the target application, creating a service instance and generating a connection task, reading the connection parameters to establish a connection with the dependent service, and re-establishing the connection if necessary, displaying the connection results.
The rapid and comprehensive connection between target applications and dependent services is achieved, the user experience is improved, and the connection delay and omissions in the existing technology are avoided.
Smart Images

Figure CN113934548B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for establishing a connection with a dependent service. Background Art
[0002] In today's Internet business systems, the application of microservice architecture is becoming more and more widespread. The use of microservice architecture can decompose relatively complex monolithic applications into a series of microservices, and realize the rapid development and maintenance of complex monolithic applications through the development and maintenance of microservices. The realization of the functions of monolithic applications depends on the microservices related to them. Therefore, before providing services to users, monolithic applications need to establish connections with the microservices they rely on; in the prior art, the target application is usually connected to the limited number of dependent services involved in the parameters by the user inputting the parameters to the target application.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] Since entering parameters once can only establish connections with a limited number of dependent services, the efficiency is low, and even if multiple entries are made, it is easy to miss establishing connections with some dependent services. The following situation often occurs: when the user is using some functions of the target application, the connection between the target application and the dependent service related to the function has not been established, which causes the user to wait too long and have a poor experience. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and apparatus for establishing a connection with a dependent service, which can quickly and comprehensively establish a connection between a target application and a dependent service, and can also display the result of establishing the connection to improve the user experience.
[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for establishing a connection with a dependent service is provided, comprising:
[0007] Get the dependent service information of the target application;
[0008] Creating a service instance for establishing a connection with the dependent service according to the dependent service information;
[0009] Generate a connection task according to the service instance;
[0010] A connection parameter related to the connection task is read, and the connection task is executed based on the connection parameter to establish a connection with the dependent service.
[0011] Optionally, obtaining the dependent service information of the target application includes:
[0012] Determining dependent service information that needs to establish a connection with the target application according to an annotation identifier in the programming language;
[0013] The dependent service information at least includes: a dependent service identifier and / or a method identifier in the dependent service.
[0014] Optionally, after creating a service instance for establishing a connection with the dependent service, the method further includes: storing the service instance in a dependent service container;
[0015] The generating a connection task according to the service instance includes:
[0016] Read the service instance from the dependent service container;
[0017] The service instance is encapsulated as the connection task, and the connection task is added to a task queue.
[0018] Optionally, the reading connection parameters related to the connection task and executing the connection task based on the connection parameters includes:
[0019] Reading the connection task from the task queue and reading the connection parameters from a preset configuration center;
[0020] Input the connection parameters into the corresponding connection task, and send a connection request to the dependent service;
[0021] Determining whether a feedback message from the dependent service is received;
[0022] If received, the execution result of the connection task is recorded as successful;
[0023] If not received, the connection task is re-added to the task queue; and when the number of times that the feedback message is not received reaches a threshold, the execution result of the connection task is recorded as a failure.
[0024] Optionally, when reading the connection parameters from a preset configuration center fails, a preset algorithm is used to generate default parameters;
[0025] The connection task is performed using the default parameters.
[0026] Optionally, after executing the connection task based on the connection parameters, the method further includes: displaying the execution result of the connection task; wherein the display content includes:
[0027] The connection task that is successfully executed, and the corresponding dependent service identifier and / or method identifier in the dependent service;
[0028] The connection task that failed to execute, as well as the corresponding dependent service ID and / or method ID in the dependent service.
[0029] Optionally, when there is a connection task that fails to execute, the display content further includes:
[0030] A visual option button to reestablish connections to all dependent services; and / or,
[0031] A visual option button to reconnect to the dependent service that failed to establish a connection; and / or,
[0032] A visual option button to reestablish a connection to a method that failed to establish a connection in a dependent service.
[0033] Optionally, after receiving a confirmation operation corresponding to the visualization option button, for a dependent service or method corresponding to the visualization option button, a connection is established with the dependent service according to any one of the methods described in claims 3-5.
[0034] According to another aspect of an embodiment of the present invention, there is provided a device for establishing a connection with a dependent service, comprising:
[0035] Determine the dependent service module to obtain the dependent service information of the target application;
[0036] A task generation module is used to create a service instance for establishing a connection with the dependent service according to the dependent service information; and generate a connection task according to the service instance;
[0037] The task execution module is used to read connection parameters related to the connection task and execute the connection task based on the connection parameters to establish a connection with the dependent service.
[0038] Optionally, the determining the dependent service module to obtain dependent service information of the target application includes:
[0039] Determining dependent service information that needs to establish a connection with the target application according to an annotation identifier in the programming language;
[0040] The dependent service information at least includes: a dependent service identifier and / or a method identifier in the dependent service.
[0041] Optionally, after creating a service instance for establishing a connection with the dependent service, the generating task module further includes: storing the service instance in a dependent service container;
[0042] The generating a connection task according to the service instance includes:
[0043] Read the service instance from the dependent service container;
[0044] The service instance is encapsulated as the connection task, and the connection task is added to a task queue.
[0045] Optionally, the task execution module reads connection parameters related to the connection task, and executes the connection task based on the connection parameters, including:
[0046] Reading the connection task from the task queue and reading the connection parameters from a preset configuration center;
[0047] Input the connection parameters into the corresponding connection task, and send a connection request to the dependent service;
[0048] Determining whether a feedback message from the dependent service is received;
[0049] If received, the execution result of the connection task is recorded as successful;
[0050] If not received, the connection task is re-added to the task queue; and when the number of times that the feedback message is not received reaches a threshold, the execution result of the connection task is recorded as a failure.
[0051] Optionally, when reading the connection parameters from the preset configuration center fails, the task execution module generates default parameters using a preset algorithm;
[0052] The connection task is performed using the default parameters.
[0053] Optionally, the device for establishing a connection with a dependent service further comprises: a display module;
[0054] The display module is used to, after executing the connection task based on the connection parameters, further include: displaying the execution result of the connection task; wherein the display content includes:
[0055] The connection task that is successfully executed, and the corresponding dependent service identifier and / or method identifier in the dependent service;
[0056] The connection task that failed to execute, as well as the corresponding dependent service ID and / or method ID in the dependent service.
[0057] Optionally, when there is a connection task that fails to execute, the display content further includes:
[0058] A visual option button to reestablish connections to all dependent services; and / or,
[0059] A visual option button to reconnect to the dependent service that failed to establish a connection; and / or,
[0060] A visual option button to reestablish a connection to a method that failed to establish a connection in a dependent service.
[0061] Optionally, when the display module receives a confirmation operation corresponding to the visualization option button, for the dependent service or method corresponding to the visualization option button, a connection is established with the dependent service according to the optional method for establishing a connection with a dependent service in the present invention.
[0062] According to another aspect of an embodiment of the present invention, there is provided an electronic device for establishing a connection with a dependent service, including:
[0063] one or more processors;
[0064] a storage device for storing one or more programs,
[0065] When the one or more programs are executed by the one or more processors, the one or more processors implement the method for establishing a connection with a dependent service provided by the present invention.
[0066] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method for establishing a connection with a dependent service provided by the present invention is implemented.
[0067] An embodiment of the above invention has the following advantages or beneficial effects: because a technical means is adopted to generate a connection task including a service instance according to the acquired dependent service information, read the connection parameters and input the corresponding connection task to achieve the target application to establish a connection with the dependent service, it overcomes the technical problems of low efficiency and easy omission of dependent services caused by establishing a connection with the dependent service by inputting parameters to the target application in the prior art, thereby achieving the technical effect of being able to quickly and comprehensively establish a connection between the target application and the dependent service, and can also display the results of the connection establishment and re-establish the connection when necessary, thereby improving the user experience.
[0068] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0070] Figure 1 is a flow chart of a method for establishing a connection with a dependent service according to a first embodiment of the present invention;
[0071] Figure 2 is a flow chart of a method for establishing a connection with a dependent service according to a second embodiment of the present invention;
[0072] Figure 3 is a flow chart of a method for executing a connection task according to a third embodiment of the present invention;
[0073] Figure 4 is a flow chart of a method for executing a connection task according to a fourth embodiment of the present invention;
[0074] Figure 5 is a schematic diagram of the architecture of a method for establishing a connection with a dependent service according to a fifth embodiment of the present invention;
[0075] Figure 6 is a schematic diagram of main modules of an apparatus for establishing a connection with a dependent service according to a sixth embodiment of the present invention;
[0076] Figure 7 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0077] Figure 8 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0078] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0079] It should be pointed out that the embodiments of the present invention and the technical features therein may be combined with each other without conflict.
[0080] Figure 1 FIG. 1 is a flow chart of a method for establishing a connection with a dependent service according to a first embodiment of the present invention. Figure 1 As shown, the methods for establishing a connection with a dependent service include:
[0081] Step S101, obtaining dependent service information of a target application;
[0082] Step S102: creating a service instance for establishing a connection with the dependent service according to the dependent service information;
[0083] Step S103: Generate a connection task according to the service instance;
[0084] Step S104: read connection parameters related to the connection task, and execute the connection task based on the connection parameters to establish a connection with the dependent service.
[0085] Among them, all dependent service information can be obtained first, a service instance can be created for each dependent service and a connection task can be generated, and connection parameters for establishing a connection can be configured in advance; based on the connection parameters, corresponding connection tasks are executed to establish a connection with each dependent service;
[0086] According to the method of the present invention, the target application can be quickly and completely connected to the dependent service, avoiding the situation in the prior art where the user establishes a connection with the dependent service only when using the target application, thereby improving the user experience.
[0087] In some embodiments, the dependent service information of the target application may be obtained as follows:
[0088] Determining dependent service information that needs to establish a connection with the target application according to an annotation identifier in the programming language;
[0089] The dependent service information at least includes: a dependent service identifier and / or a method identifier in the dependent service.
[0090] The annotation identifier in the programming language can be regarded as a kind of annotation mechanism in the programming language, and aspects can be declared based on annotations, such as Java annotations in the Java language;
[0091] Taking the target application as a login service and the dependent service as a user service as an example, in the method of the present invention, a feasible annotation identifier statement can be set as the following statement:
[0092]
[0093] Among them, UserService is the user service identifier, and LoginService is the login service identifier; @Resource can declare that the user service is a dependent service of the login service, and the dependency can be automatically injected using the spring container; @WarmUpAnnotation can declare that a connection to this dependent service needs to be established;
[0094] The dependency service information may include only the dependency service identifier, or may also include the method identifier in the dependency service; when the dependency service information includes only the dependency service identifier, the method for establishing a connection in the present invention may be used to enable the target application to establish a connection with the entire dependency service, or to establish a connection with all methods in the dependency service; when the dependency service information also includes the method identifier in the dependency service, the method for establishing a connection in the present invention may be used to enable the target application to establish a connection with the method specified in the dependency service.
[0095] In some embodiments, after creating a service instance for establishing a connection with the dependent service, the method further includes: storing the service instance in a dependent service container;
[0096] The generating a connection task according to the service instance includes:
[0097] Read the service instance from the dependent service container;
[0098] The service instance is encapsulated as the connection task, and the connection task is added to a task queue.
[0099] After creating a service instance, you can store the service instance in a dependent service container, which can be used to manage all service instances that need to establish connections;
[0100] The generated connection task is stored in the task queue; when the connection task exists in the task queue, the method of the present invention can be used to execute the connection task.
[0101] To facilitate understanding of the method flow in the above embodiment, please refer to Figure 2 ; Figure 2 FIG. 1 is a flow chart of a method for establishing a connection with a dependent service according to a second embodiment of the present invention. Figure 2 As shown, including:
[0102] Step S201, target application starts;
[0103] Step S202: Determine the dependent service information according to the annotation identifier in the program language; specifically, after the target application is started, the dependent service information can be determined according to the annotation identifier in the program language scanned during the program startup and execution process; wherein the dependent service information includes the dependent service identifier and / or the method identifier in the dependent service;
[0104] Step S203: Create a service instance for establishing a connection according to the dependent service information;
[0105] Step S204: store the service instance in the dependent service container;
[0106] Step S205: read the service instance from the dependent service container, and encapsulate the service instance as a connection task;
[0107] Step S206, adding the connection task to the task queue;
[0108] Step S207: read the connection parameters to execute the connection tasks in the task queue; wherein the connection parameters may be pre-configured and stored in the configuration center.
[0109] In some embodiments, the reading of connection parameters related to the connection task and executing the connection task based on the connection parameters includes:
[0110] Reading the connection task from the task queue and reading the connection parameters from a preset configuration center;
[0111] Input the connection parameters into the corresponding connection task, and send a connection request to the dependent service;
[0112] Determining whether a feedback message from the dependent service is received;
[0113] If received, the execution result of the connection task is recorded as successful;
[0114] If not received, the connection task is re-added to the task queue; and when the number of times that the feedback message is not received reaches a threshold, the execution result of the connection task is recorded as a failure.
[0115] In some embodiments, when reading the connection parameters from a preset configuration center fails, a preset algorithm is used to generate default parameters; the connection task is performed using the default parameters; specifically, the default parameters can be generated randomly or based on restrictions related to the dependent service.
[0116] In some practical applications, connection parameters or default parameters can be used as input parameters of a service instance; a connection request sent to a dependent service can be regarded as a call request or access request sent to the dependent service; obtaining a feedback message can be regarded as successfully establishing a connection with the dependent service, and the execution result of the connection task can be recorded as success; it should be noted that the above feedback message can be a feedback message indicating success or failure, such as: it can be a feedback message indicating that a connection is successfully established with the dependent service and a request result corresponding to the input parameter is obtained, or it can be a feedback message indicating that a connection is successfully established with the dependent service but a request result corresponding to the input parameter is not obtained;
[0117] The following examples illustrate:
[0118] A service provided by a dependent service is to query a user name by inputting a character string; wherein, valid character strings that can be queried and obtain results are: 100 numbers from 00 to 99;
[0119] When the parameter of the input service instance is "00", the feedback message is a feedback message of successfully obtaining the request result, which can be specifically the user name corresponding to "00", that is, the feedback message indicates that the connection with the dependent service is successfully established and the request result corresponding to the input parameter is obtained; when the parameter of the input service instance is a parameter other than the 100 numbers from 00 to 99, such as "780" or "XYZ", the feedback message is a feedback message of not obtaining the request result, which can be specifically a message such as "Unable to find information" or "Input error", that is, the feedback message indicates that the connection with the dependent service is successfully established but the request result corresponding to the input parameter is not obtained.
[0120] To facilitate understanding of the method flow for executing the connection task in the above embodiment, please refer to Figure 3 and Figure 4 .
[0121] Figure 3 FIG. 4 is a flow chart of a method for executing a connection task according to a third embodiment of the present invention. Figure 3 As shown, including:
[0122] Step S301: obtain a connection task and corresponding connection parameters, input the connection parameters into the connection task, and send a connection request to the dependent service; wherein the connection task can be read from the task queue; the connection parameters can be read from the configuration center or generated randomly;
[0123] Step S302: whether a feedback message from the dependent service is received; the feedback message may indicate success or failure; if received, it can be considered that a connection with the dependent service is successfully established, and step S303 is executed; if not received, step S304 is executed;
[0124] Step S303, record the execution result of the connection task as success;
[0125] Step S304: determine whether the number of times the feedback message is not received reaches the number threshold; if so, execute step S305; if not, execute step S306;
[0126] Step S305, record the execution result of the connection task as failure;
[0127] Step S306: The connection task may be added back to the task queue for execution again.
[0128] Figure 4FIG. 4 is a flow chart of a method for executing a connection task according to a fourth embodiment of the present invention; Figure 4 As shown, multiple execution engines can be set. After the execution engine obtains the connection task from the task queue, it can execute these connection tasks in parallel to achieve the effect of quickly establishing a connection with the dependent service; Figure 4 In the execution engine, the method flow for executing the connection task includes:
[0129] Step S401, reading a connection task from a task queue;
[0130] Step S402: Read connection parameters corresponding to the connection task from the configuration center;
[0131] Step S403: Is the reading successful? If yes, go to step S404; if no, go to step S405;
[0132] Step S404: input the read connection parameters into the connection task, and send a connection request to the dependent service;
[0133] Step S405: Generate default parameters using a preset algorithm, input the default parameters into the connection task, and send a connection request to the dependent service;
[0134] Step S406, executing the connection task;
[0135] Step S407: record the execution result; the execution result may include: success or failure;
[0136] Among them, whether the execution result of the connection task is successful can be determined by whether a feedback message from the dependent service is received; in some practical applications, the execution result can also record the dependent service identifier corresponding to the connection task and / or the method identifier in the dependent service.
[0137] In some embodiments, after executing the connection task based on the connection parameters, the method further includes: displaying the execution result of the connection task; wherein the display content includes:
[0138] The connection task that is successfully executed, and the corresponding dependent service identifier and / or the method identifier in the dependent service; the connection task that is failed to be executed, and the corresponding dependent service identifier and / or the method identifier in the dependent service.
[0139] In some practical applications, the connection parameters / default parameters corresponding to the dependent service and / or the connection parameters / default parameters corresponding to the method in the dependent service may also be recorded in the execution result of the connection task;
[0140] Displaying the execution results can enable users to more intuitively understand the results of establishing connections with dependent services, and can also facilitate re-establishing connections in subsequent method steps;
[0141] Among them, displaying the connection parameters / default parameters can facilitate the user to analyze the failed connection tasks and determine whether the connection failure is caused by the connection parameters / default parameters, and then optimize the configuration of the connection parameters or the generation method of the default parameters.
[0142] In some embodiments, when there is a connection task that fails to execute, the display content further includes:
[0143] A visual option button for re-establishing connections to all dependent services; and / or, a visual option button for re-establishing connections to dependent services that failed to establish connections; and / or, a visual option button for re-establishing connections to methods that failed to establish connections in dependent services.
[0144] In some embodiments, after receiving a confirmation operation corresponding to the visualization option button, for the dependent service or method corresponding to the visualization option button, a connection can be established with the dependent service according to the optional method of establishing a connection with the dependent service in the present invention.
[0145] By setting optional visual option buttons, users can flexibly choose the way to re-establish the connection, which may include: re-establishing the connection to all dependent services that the target application depends on, re-establishing the connection to the optional dependent services, and re-establishing the connection to the optional methods in the optional dependent services;
[0146] In the process of re-establishing the connection, the service instance can be directly obtained from the above-mentioned dependent service container without having to create a service instance based on the dependent service information, thereby improving the overall efficiency.
[0147] To facilitate understanding of the method architecture in the embodiment of the present invention, please refer to Figure 5 ; Figure 5 is a schematic diagram of the architecture of a method for establishing a connection with a dependent service according to a fifth embodiment of the present invention. Figure 5 As shown, including:
[0148] Target application 500, configuration center 506, result management center 507; in target application 500, including: dependent service information 501, service instance 502, dependent service container 503, task queue 504, execution engine 505;
[0149] The target application 500 needs to establish a connection with the dependent service on which it depends; in the target application 500, the dependent service information 501 may include a dependent service identifier and / or a method identifier in the dependent service; a service instance 502 for establishing a connection with the dependent service may be created according to the dependent service information 501; the created service instance 502 may be stored in a dependent service container 503, and the dependent service container 503 may be used to manage service instances; a connection task may be generated according to the service instance in the dependent service container 503; a task queue 504 may be used to store the connection task;
[0150] The configuration center 506 may be used to store connection parameters, which may be used to perform connection tasks;
[0151] The execution engine 505 can read connection tasks from the task queue 504, read connection parameters from the configuration center 506, and execute corresponding connection tasks based on the connection parameters, and can also record the execution results; the result management center 507 can be used to display the execution results, and can provide a visual option button for re-establishing the connection.
[0152] In summary, the method for establishing a connection with a dependent service in the present invention can be accomplished through the above-mentioned architecture.
[0153] Figure 6 is a schematic diagram of main modules of an apparatus for establishing a connection with a dependent service according to a sixth embodiment of the present invention, such as Figure 6 As shown, the device 600 for establishing a connection with a dependent service includes:
[0154] Determine dependent service module 601, used to obtain dependent service information of the target application;
[0155] A task generation module 602 is used to create a service instance for establishing a connection with the dependent service according to the dependent service information; and to generate a connection task according to the service instance;
[0156] The task execution module 603 is used to read the connection parameters related to the connection task, and execute the connection task based on the connection parameters to establish a connection with the dependent service.
[0157] Among them, all dependent service information can be obtained first, a service instance can be created for each dependent service and a connection task can be generated, and connection parameters for establishing a connection can be configured in advance; based on the connection parameters, corresponding connection tasks are executed to establish a connection with each dependent service;
[0158] According to the method of the present invention, the target application can be quickly and completely connected to the dependent service, avoiding the situation in the prior art where the user establishes a connection with the dependent service only when using the target application, thereby improving the user experience.
[0159] In some embodiments, the determining the dependent service module to obtain the dependent service information of the target application includes:
[0160] Determining dependent service information that needs to establish a connection with the target application according to an annotation identifier in the programming language;
[0161] The dependent service information at least includes: a dependent service identifier and / or a method identifier in the dependent service.
[0162] The annotation identifier in the programming language can be regarded as a kind of annotation mechanism in the programming language, and aspects can be declared based on annotations, such as Java annotations in the Java language;
[0163] Taking the target application as a login service and the dependent service as a user service as an example, in the method of the present invention, a feasible annotation identifier statement can be set as the following statement:
[0164]
[0165]
[0166] Among them, UserService is the user service identifier, and LoginService is the login service identifier; @Resource can declare that the user service is a dependent service of the login service, and the dependency can be automatically injected using the spring container; @WarmUpAnnotation can declare that a connection to this dependent service needs to be established;
[0167] The dependency service information may include only the dependency service identifier, or may also include the method identifier in the dependency service; when the dependency service information includes only the dependency service identifier, the method for establishing a connection in the present invention may be used to enable the target application to establish a connection with the entire dependency service, or to establish a connection with all methods in the dependency service; when the dependency service information also includes the method identifier in the dependency service, the method for establishing a connection in the present invention may be used to enable the target application to establish a connection with the method specified in the dependency service.
[0168] In some embodiments, after creating a service instance for establishing a connection with the dependent service, the generating task module further includes: storing the service instance in a dependent service container;
[0169] The generating a connection task according to the service instance includes:
[0170] Read the service instance from the dependent service container;
[0171] The service instance is encapsulated as the connection task, and the connection task is added to a task queue.
[0172] After creating a service instance, you can store the service instance in a dependent service container, which can be used to manage all service instances that need to establish connections;
[0173] The generated connection task is stored in the task queue; when the connection task exists in the task queue, the method of the present invention can be used to execute the connection task.
[0174] In some embodiments, the task execution module reads connection parameters related to the connection task, and executes the connection task based on the connection parameters, including:
[0175] Reading the connection task from the task queue and reading the connection parameters from a preset configuration center;
[0176] Input the connection parameters into the corresponding connection task, and send a connection request to the dependent service;
[0177] Determining whether a feedback message from the dependent service is received;
[0178] If received, the execution result of the connection task is recorded as successful;
[0179] If not received, the connection task is re-added to the task queue; and when the number of times that the feedback message is not received reaches a threshold, the execution result of the connection task is recorded as a failure.
[0180] In some embodiments, when reading the connection parameters from the preset configuration center fails, the task execution module generates default parameters using a preset algorithm;
[0181] The connection task is performed using the default parameters.
[0182] Specifically, default parameters can be generated randomly or according to constraints related to dependent services.
[0183] In some practical applications, connection parameters or default parameters can be used as input parameters of a service instance; a connection request sent to a dependent service can be regarded as a call request sent to the dependent service; and a feedback message obtained can be regarded as establishing a connection with the dependent service. It should be noted that the above feedback message can be a feedback message indicating success or failure, such as: it can be a feedback message indicating that the dependent service is successfully called and the request result corresponding to the input parameter is obtained, or it can be a feedback message indicating that the dependent service is successfully called but the request result corresponding to the input parameter is not obtained;
[0184] The following examples illustrate:
[0185] A service provided by a dependent service is to query a user name by inputting a character string; wherein, valid character strings that can be queried and obtain results are: 100 numbers from 00 to 99;
[0186] When the parameter of the input service instance is "00", the feedback message is a feedback message of successfully obtaining the request result, which can be specifically the user name corresponding to "00", that is, the feedback message indicates that the connection with the dependent service is successfully established and the request result corresponding to the input parameter is obtained; when the parameter of the input service instance is a parameter other than the 100 numbers from 00 to 99, such as "780" or "XYZ", the feedback message is a feedback message of not obtaining the request result, which can be specifically a message such as "Unable to find information" or "Input error", that is, the feedback message indicates that the connection with the dependent service is successfully established but the request result corresponding to the input parameter is not obtained.
[0187] In some embodiments, the means for establishing a connection with a dependent service further comprises: a presentation module;
[0188] The display module is used to, after executing the connection task based on the connection parameters, further include: displaying the execution result of the connection task; wherein the display content includes:
[0189] The connection task that is successfully executed, and the corresponding dependent service identifier and / or the method identifier in the dependent service; the connection task that is failed to be executed, and the corresponding dependent service identifier and / or the method identifier in the dependent service.
[0190] In some practical applications, the connection parameters / default parameters corresponding to the dependent service and / or the connection parameters / default parameters corresponding to the method in the dependent service may also be recorded in the execution result of the connection task;
[0191] Displaying the execution results can enable users to more intuitively understand the results of establishing connections with dependent services, and can also facilitate re-establishing connections in subsequent method steps;
[0192] Among them, displaying the connection parameters / default parameters can facilitate the user to analyze the failed connection tasks and determine whether the connection failure is caused by the connection parameters / default parameters, and then optimize the configuration of the connection parameters or the generation method of the default parameters.
[0193] In some embodiments, when there is a connection task that fails to execute, the display content further includes:
[0194] A visual option button for re-establishing connections to all dependent services; and / or, a visual option button for re-establishing connections to dependent services that failed to establish connections; and / or, a visual option button for re-establishing connections to methods that failed to establish connections in dependent services.
[0195] In some embodiments, when the display module receives a confirmation operation corresponding to the visualization option button, for the dependent service or method corresponding to the visualization option button, a connection with the dependent service can be established according to the optional method of establishing a connection with the dependent service in the present invention.
[0196] By setting optional visual option buttons, users can flexibly choose the way to re-establish the connection, which may include: re-establishing the connection to all dependent services that the target application depends on, re-establishing the connection to the optional dependent services, and re-establishing the connection to the optional methods in the optional dependent services;
[0197] In the process of re-establishing the connection, the service instance can be directly obtained from the above-mentioned dependent service container without having to create a service instance based on the dependent service information, thereby improving the overall efficiency.
[0198] Figure 7 An exemplary system architecture 700 is shown in which the method for establishing a connection with a dependent service or the apparatus for establishing a connection with a dependent service according to the embodiments of the present invention can be applied.
[0199] like Figure 7 As shown, system architecture 700 may include terminal devices 701, 702, 703, network 704 and server 705. Network 704 is used to provide a medium for communication links between terminal devices 701, 702, 703 and server 705. Network 704 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0200] Users can use terminal devices 701, 702, and 703 to interact with server 705 through network 704 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 701, 702, and 703, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0201] The terminal devices 701 , 702 , and 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0202] The server 705 may be a server that provides various services, such as a backend management server (only for example) that supports shopping websites browsed by users using the terminal devices 701, 702, and 703. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only for example) to the terminal device.
[0203] It should be noted that the method for establishing a connection with a dependent service provided in the embodiment of the present invention is generally executed by the server 705 , and accordingly, the device for establishing a connection with a dependent service is generally arranged in the server 705 .
[0204] It should be understood that Figure 7 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0205] Reference below Figure 8 , which shows a schematic diagram of the structure of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8 The terminal 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 invention.
[0206] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0207] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage section 808 as needed.
[0208] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are executed.
[0209] It should be noted that 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 above two. The computer-readable storage medium may 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 of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal 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 computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0210] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0211] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a module for determining dependent services, a module for generating tasks, a module for executing tasks, and a module for displaying tasks. The names of these modules do not, in some cases, constitute limitations on the modules themselves.
[0212] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: step S101, obtaining the dependent service information of the target application; step S102, creating a service instance for establishing a connection with the dependent service according to the dependent service information; step S103, generating a connection task according to the service instance; step S104, reading the connection parameters related to the connection task, and executing the connection task based on the connection parameters to establish a connection with the dependent service.
[0213] According to the technical solution of the embodiment of the present invention, a technical means is adopted to generate a connection task including a service instance according to the acquired dependent service information, read the connection parameters and input the corresponding connection task to realize the target application to establish a connection with the dependent service. Therefore, the technical problems of low efficiency and easy omission of dependent services caused by establishing a connection with the dependent service by inputting parameters to the target application in the prior art are overcome, thereby achieving the technical effect of being able to quickly and comprehensively establish a connection between the target application and the dependent service, and also being able to display the results of the connection establishment and re-establish the connection when necessary, thereby improving the user experience.
[0214] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for establishing a connection with a dependent service, characterized in that: include: Get the dependent service information of the target application; Creating a service instance for establishing a connection with the dependent service according to the dependent service information; Generate a connection task according to the service instance; Reading connection parameters related to the connection task, and executing the connection task based on the connection parameters to establish a connection with the dependent service; The step of obtaining the dependent service information of the target application includes: Determining dependent service information that needs to establish a connection with the target application according to an annotation identifier in the programming language; The dependent service information at least includes: a dependent service identifier and / or a method identifier in the dependent service.
2. The method according to claim 1, characterized in that After creating a service instance for establishing a connection with the dependent service, the method further includes: storing the service instance in a dependent service container; The generating a connection task according to the service instance includes: Read the service instance from the dependent service container; The service instance is encapsulated as the connection task, and the connection task is added to a task queue.
3. The method according to claim 2, characterized in that The reading of connection parameters related to the connection task and executing the connection task based on the connection parameters includes: Reading the connection task from the task queue and reading the connection parameters from a preset configuration center; Input the connection parameters into the corresponding connection task, and send a connection request to the dependent service; Determining whether a feedback message from the dependent service is received; If received, the execution result of the connection task is recorded as successful; If not received, the connection task is re-added to the task queue; and when the number of times that the feedback message is not received reaches a threshold, the execution result of the connection task is recorded as a failure.
4. The method according to claim 3, characterized in that Also includes: When reading the connection parameters from the preset configuration center fails, a preset algorithm is used to generate default parameters; The connection task is performed using the default parameters.
5. The method according to claim 3, characterized in that: After executing the connection task based on the connection parameters, the method further includes: displaying the execution result of the connection task; wherein the display content includes: The connection task that is successfully executed, and the corresponding dependent service identifier and / or method identifier in the dependent service; The connection task that failed to execute, as well as the corresponding dependent service ID and / or method ID in the dependent service.
6. The method according to claim 5, characterized in that When there is a connection task that fails to execute, the display content also includes: A visual option button to reestablish connections to all dependent services; and / or, A visual option button to reconnect to the dependent service that failed to establish a connection; and / or, A visual option button to reestablish a connection to a method that failed to establish a connection in a dependent service.
7. The method according to claim 6, characterized in that After receiving a confirmation operation corresponding to the visualization option button, for the dependent service or method corresponding to the visualization option button, a connection is established with the dependent service according to the method described in any one of claims 2 to 4.
8. A device for establishing a connection with a dependent service, characterized in that: include: Determine the dependent service module to obtain the dependent service information of the target application; A task generation module is used to create a service instance for establishing a connection with the dependent service according to the dependent service information; and generate a connection task according to the service instance; An execution task module, configured to read connection parameters related to the connection task, and execute the connection task based on the connection parameters to establish a connection with the dependent service; The module for determining dependent services is specifically used to: determine dependent service information that needs to establish a connection with the target application according to an annotation identifier in a programming language; The dependent service information at least includes: a dependent service identifier and / or a method identifier in the dependent service.
9. An electronic device for establishing a connection with a dependent service, characterized in that: include: one or more processors; a storage device 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 implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Connection preheating method and system based on distributed service invocation
CN109522055A
Data query method and device
CN110674172A