Service invocation method, apparatus, device, and storage medium
By using a generic service interface during service calls, the problem of frequent modifications to service function code and interfaces is solved, achieving efficient service interface management and improving development efficiency.
Patent Information
- Application Number
- CN202210469804.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-28
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2042-04-28
AI Technical Summary
In existing technologies, when a service is called, the service function code and service interface need to be added or modified every time a service function is added or modified. This leads to chaotic service interface management, increases the workload of code development and maintenance costs, and reduces development efficiency.
By receiving service call requests from clients, determining the interface call parameters of the general service interface, and sending requests to the second server based on these parameters to execute preset service functions, receiving and feeding back response data, the same general service interface can be used to call functions of different operation objects.
The number of service interfaces was reduced, management efficiency was improved, code development workload and maintenance costs were reduced, and development efficiency was increased.
Smart Images

Figure CN114780263B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer, and particularly relates to a service calling method and device, equipment and storage medium. BACKGROUND
[0002] With the rapid development of computer and network technology, service calling technology has been more and more widely applied.
[0003] In the prior art, service calling is usually to develop service function code first, and then provide a service interface to the outside. The external application or external service can execute the above-mentioned service function by calling the service interface.
[0004] However, in the above implementation, each time a service function is added or modified, the service function code and the service interface need to be added or modified, which not only increases the number of service interfaces, leading to chaotic service interface management, but also increases the code development workload, resulting in high service maintenance cost and low development efficiency. SUMMARY
[0005] In order to solve the above technical problems, the present disclosure provides a service calling method, device, equipment and storage medium.
[0006] In a first aspect, the present disclosure provides a service calling method applied to a first service end, comprising:
[0007] receiving a first service calling request sent by a client, and determining an interface calling parameter of a general service interface based on the service calling request; wherein the interface calling parameter comprises a service operation object, a target service identifier, a target service operation value and a target value type;
[0008] based on the interface calling parameter and the general service interface, sending a second service calling request to a second service end, so that the second service end executes a preset service function corresponding to the target service identifier on the service operation object according to the target service operation value and the target value type;
[0009] receiving a calling response data fed back by the second service end, and sending the calling response data to the client.
[0010] In an optional implementation, in the case of data processing on a database, the service operation object is a storage object in the database, and the preset service function comprises at least one of an object assignment function, a value deletion function, a value accumulation function, a first value insertion function, a second value insertion function, a first numerical value update function and a second numerical value update function.
[0011] In an optional implementation, the database is a document database.
[0012] In a second aspect, the disclosure provides a service calling method applied to a second service end, comprising:
[0013] receiving a second service calling request sent by a first service end; wherein the second service calling request is generated based on a service operation object, a target service identifier, a target service operation value, a target value type and a general service interface contained in a first service calling request; the first service calling request is sent by a client to the first service end;
[0014] performing a preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type, to generate calling response data;
[0015] sending the calling response data to the first service end.
[0016] In an optional implementation, the storage structure of the target service operation value and the target value type is a preset structure;
[0017] The performing of the preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type, to generate calling response data comprises:
[0018] obtaining a numerical value corresponding to the target value type from the preset structure as the target service operation value;
[0019] determining a target service processing function corresponding to the target service identifier from a function mapping relationship; wherein the function mapping relationship is used to record the correspondence between a preset service identifier and a preset service processing function; the preset service processing function is a function for executing a preset service function;
[0020] calling the target service processing function of the service operation object based on the target service operation value, to perform the preset service function corresponding to the target service identifier on the service operation object, to generate the calling response data.
[0021] In an optional implementation, in the case of performing data processing on a database and the database is a document database, the second service calling request further comprises a first object version identifier;
[0022] Before the performing of the preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type, to generate calling response data, the method further comprises:
[0023] If it is determined that the first object version identifier and a second object version identifier of the service operation object stored in the document database are consistent, a step of triggering execution of the preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type to generate calling response data is performed.
[0024] After the step of generating calling response data by executing the preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type is performed, the method further includes:
[0025] updating the second object version identifier, and the updated second object version identifier is not repeated with each historical second object version identifier.
[0026] In a third aspect, the present disclosure provides a service calling device configured in a first service end, the device comprising:
[0027] an interface calling parameter determination module configured to receive a first service calling request sent by a client and determine an interface calling parameter of a general service interface based on the service calling request, wherein the interface calling parameter comprises a service operation object, a target service identifier, a target service operation value, and a target value type;
[0028] a second service calling request sending module configured to send a second service calling request to a second service end based on the interface calling parameter and the general service interface, so that the second service end executes a preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type;
[0029] a calling response data receiving module configured to receive calling response data fed back by the second service end and send the calling response data to the client.
[0030] In a fourth aspect, the present disclosure further provides a service calling device configured in a second service end, the device comprising:
[0031] a second service calling request receiving module configured to receive a second service calling request sent by a first service end, wherein the second service calling request is generated based on a service operation object, a target service identifier, a target service operation value, and a target value type contained in a first service calling request and a general service interface, and the first service calling request is sent by a client to the first service end;
[0032] a calling response data generating module configured to execute a preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type to generate calling response data;
[0033] The calling response data sending module is configured to send the calling response data to the first service end.
[0034] In a fifth aspect, the present disclosure provides an electronic device, which comprises:
[0035] a processor;
[0036] a memory configured to store executable instructions;
[0037] The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the service calling method described in any of the embodiments of the present disclosure.
[0038] In a sixth aspect, the present disclosure provides a computer readable storage medium storing a computer program, when the computer program is executed by a processor, the processor implements the service calling method described in any of the embodiments of the present disclosure.
[0039] In the service calling method provided by the embodiments of the present disclosure, the first service calling request sent by the client is received, and the interface calling parameter of the general service interface is determined based on the first service calling request; wherein the interface calling parameter comprises a service operation object, a target service identifier, a target service operation value and a target value type; based on the interface calling parameter and the general service interface, the second service calling request is sent to the second service end, so that the second service end executes the preset service function corresponding to the target service identifier on the service operation object according to the target service operation value and the target value type; the calling response data fed back by the second service end is received, and the calling response data is sent to the client; the same general service interface can be called by changing the service operation object and the target service identifier, so as to realize different service functions on different operation objects, avoiding the problem that the service function code and the service interface are added or modified every time the service function is added or modified, which can not only reduce the number of service interfaces and improve the service interface management efficiency, but also greatly reduce the code development workload, save the service maintenance cost and improve the development efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0040] The above and other features, advantages, and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals refer to the same or similar elements. It should be understood that the drawings are schematic, and the original and elements are not necessarily drawn according to the scale.
[0041] Figure 1 A structural schematic diagram of a service calling system provided by the embodiments of the present disclosure;
[0042] Figure 2A flowchart of a service calling method applied to a first service end is provided for an embodiment of the present disclosure.
[0043] Figure 3 A flowchart of a service calling method applied to a second service end is provided for an embodiment of the present disclosure.
[0044] Figure 4 A structural diagram of a service calling device configured in a first service end is provided for an embodiment of the present disclosure.
[0045] Figure 5 A structural diagram of a service calling device configured in a second service end is provided for an embodiment of the present disclosure.
[0046] Figure 6 A structural diagram of an electronic device is provided for an embodiment of the present disclosure. DETAILED DESCRIPTION
[0047] Embodiments of the present disclosure will be described in more detail by referring to the drawings. Although certain embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, but rather the embodiments are provided to more completely understand the present disclosure. It is understood that the drawings and embodiments of the present disclosure are for exemplary purposes only and are not intended to limit the scope of the present disclosure.
[0048] It should be understood that each step recited in the method embodiments of the present disclosure can be executed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the execution of the steps shown. The scope of the present disclosure is not limited in this respect.
[0049] The term “comprising” and variations thereof as used herein are open-ended, that is, “including but not limited to”. The term “based on” is “based, at least in part, on”. The term “one embodiment” means “at least one embodiment”; the term “another embodiment” means “at least one additional embodiment”; the term “some embodiments” means “at least some embodiments”. Related definitions will be given in the description below.
[0050] It should be noted that the terms “first”, “second”, and the like mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not intended to limit the order or interdependence of the functions performed by these devices, modules or units.
[0051] It should be noted that the terms “one”, “multiple” in the present disclosure are illustrative and not restrictive, and those skilled in the art should understand that unless otherwise explicitly stated in the context, it should be understood as “one or more”.
[0052] The names of the messages or information exchanged between the plurality of devices in the embodiments of the present disclosure are only for illustrative purposes, and are not intended to limit the scope of the messages or information.
[0053] In order to facilitate the understanding of the overall scheme, the present disclosure first introduces a service calling system, specifically, the service calling system includes a client, a first server and a second server. The explanations of related terms and steps in the system embodiment can be seen in the subsequent embodiment descriptions.
[0054] Figure 1 A structural schematic diagram of a service calling system provided by the embodiments of the present disclosure. The service calling system 100 includes a client 101, a first server 102 and a second server 103, the client 101 is connected with the first server through communication, and the first server is connected with the second server through communication.
[0055] The client 101 is a user terminal installing an application program, which is at least used to send a first service calling request to the first server.
[0056] The client 101 can be a mobile terminal such as a smart phone, a personal digital assistant (PDA), a tablet computer (Tablet PC), a PMP (portable multimedia player), a vehicle terminal (such as a vehicle navigation terminal), a wearable device, a notebook computer, etc., and a fixed terminal such as a digital television, a desktop computer, a smart home device, etc.
[0057] The first server 102 is a terminal where the service corresponding to the application program is located, which is at least used to receive the first service calling request sent by the client 101, determine the interface calling parameters of the general service interface based on the first service calling request, send a second service calling request to the second server 103 based on the interface calling parameters and the general service interface, so that the second server 103 executes the preset service function corresponding to the target service identifier on the service operation object according to the target service operation value and the target value type, receives the calling response data fed back by the second server 103, and sends the calling response data to the client 101.
[0058] The first server 102 can be a notebook computer, a desktop computer, a server or a server cluster, etc.
[0059] The second service end 103 is a terminal where a service called by the first service end 102 is located, and is at least used for receiving a second service call request sent by the first service end 102, performing a preset service function corresponding to a target service identifier on a service operation object based on a target service operation value and a target value type, generating a call response data, and sending the call response data to the first service end 102.
[0060] The second service end 103 can be a notebook computer, a desktop computer, a server or a server cluster, etc.
[0061] In the embodiment of the present disclosure, after receiving the first service call request sent by the client, the first service end determines the interface call parameter of the general service interface based on the first service call request, and then sends the second service call request to the second service end based on the interface call parameter and the general service interface, so that the second service end performs the preset service function corresponding to the target service identifier on the service operation object according to the target service operation value and the target value type, finally receives the call response data fed back by the second service end, and sends the call response data to the client.
[0062] After receiving the second service call request sent by the first service end, the second service end performs the preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type, generates the call response data, and sends the call response data to the first service end.
[0063] In the service call system provided by the embodiment of the present disclosure, the service function call is realized based on the interface call parameter and the general service interface, so that the calls of multiple service functions are realized through the same general service interface, and the efficiency of service call is improved.
[0064] Based on the above service call system, the embodiment of the present disclosure further provides a service call method applied to the first service end. The service call method applied to the first service end can be applied to the calling between services in the server backend, for example, can be applied to the data processing in the online teaching scene, and can also be applied to the data access scene of live stream or video stream, etc. The method can be executed by a service call device configured in the first service end. The device can be realized by software and / or hardware, and the device can be integrated in the electronic device corresponding to the first service end. The electronic device can include but is not limited to, such as notebook computer, desktop computer, server or server cluster, etc.
[0065] Figure 2 A flowchart of a service call method applied to the first service end provided by the embodiment of the present disclosure is shown. Referring to FIG. 4, Figure 2 The service call method applied to the first service end includes:
[0066] S201, receiving a first service call request sent by a client, and determining an interface call parameter of a general service interface based on the first service call request.
[0067] The first service call request refers to an interface call request generated by the client when remotely calling a service, and at least includes description information of the client (such as client name or number, system type, system version, etc.), description information of the application program, description information of the called service (such as service name or number, etc.), and interface description information, so that the first service end can locate the specific interface and service according to the above information.
[0068] The general service interface refers to a service interface with unified interface definition and interface parameter, but can realize the calling of multiple preset service functions. The preset service function is a service function pre-integrated in the general service interface. In the embodiment of the present disclosure, the general service interface can be abstractly defined as: O→OP[opType](V[T]). Wherein, O is a service operation object, which is the object processed by the called preset service function; OP is the interface name of the general service interface; opType is the service identifier of the preset service function, which can be the service name (full name or short name), service number, etc.; OP[opType] indicates that the preset service function corresponding to the service identifier opType is executed on the service operation object O; V is the service operation value, that is, the value required for executing the preset service function; T is the value type, that is, the data type of the service operation value, such as string type, floating point type, etc. According to the definition of the general service interface, when different preset service functions need to be executed on different service operation objects, only the service operation object O and the service identifier opType of the preset service function need to be modified, and the calling of the general service interface can be realized, without the need to modify or add the code for realizing the corresponding preset service function.
[0069] The interface call parameter refers to the parameter input when calling the general service interface, and the specific parameters contained therein can be determined according to the definition of the general service interface. For the general service interface O→OP[opType](V[T]) described above, the interface call parameter includes the service operation object O, the target service identifier opType, the target service operation value V and the target value type T.
[0070] Specifically, when the client wants to execute a certain function in the application program, and the implementation of the function needs to rely on a certain service in the first service end, the client will initiate a first service call request to the first service end through the service call interface provided by the first service end.
[0071] The first service end analyzes the first service call request after receiving the first service call request sent by the client, obtains various parameters contained in the first service call request, and judges whether the service called by the client is in the service end. If yes, the first service end directly executes the called service according to various parameters obtained by analysis. If not, it means that the service called by the client depends on the service in another service end (i.e. the second service end) different from the first service end. At this time, the first service end needs to parse the first service call request according to the general service interface provided by the second service end, and obtain the corresponding interface call parameters, so as to execute the call of the general service interface subsequently.
[0072] S202, based on the interface call parameter and the general service interface, a second service call request is sent to the second service end, so that the second service end executes the preset service function corresponding to the target service identifier on the service operation object according to the target service operation value and the target value type.
[0073] The second service call request is used to initiate a remote service call to the second service end.
[0074] Specifically, the first service end takes the obtained interface call parameter as input data, calls the general service interface, and initiates a second service call request to the second service end. After receiving the second service call request, the second service end parses the corresponding various parameters, i.e. the service operation object, the target service identifier, the target service operation value and the target value type. Then, the second service end executes the preset service function corresponding to the target service identifier on the service operation object, so that the service operation object or the value of the service operation object produces the target service operation value change according to the preset service function.
[0075] S203, receiving the call response data fed back by the second service end, and sending the call response data to the client.
[0076] Specifically, after the above-mentioned preset service function processing of the second service end, a certain result can be produced, for example, the execution result feedback of whether the preset service function corresponding to the target service identifier is successfully executed, or some specific data feedback to the client. Then, the second service end feeds back the above-mentioned result as the call response data of the second service call request to the first service end. The first service end takes the call response data as the call response data of the first service call request, and sends it to the client.
[0077] Taking the height of user a recorded in the database as 180cm and the blood type as A type blood as an example, the service call method of the embodiment of the present disclosure and the service function integration method in the related art are described.
[0078] The service calling method of the embodiments of the present disclosure only needs to call the general service interface twice, that is, a.height→OP[Upsert](180[Int]) and a.blood→OP[Upsert](A[String]).
[0079] The service function integration method in the related art may not need to modify the service interface, but needs to first add a code segment for adding a height field to the user a and assigning a value 180 to the user a in the service code corresponding to the service interface. Then, a code segment for adding a blood type field to the user a and assigning a value A to the user a is added.
[0080] According to the above example, it can be understood that the general service interface provided by the embodiments of the present disclosure does not need to be re-modified or newly added for the code for implementing the preset service function corresponding to the different service operation objects, and different preset service functions can be quickly implemented on different service operation objects.
[0081] In the service calling method applied to the first service end provided by the embodiments of the present disclosure, the first service calling request sent by the client is received, the interface calling parameter of the general service interface is determined based on the first service calling request, the second service calling request is sent to the second service end based on the interface calling parameter and the general service interface, so that the second service end executes the preset service function corresponding to the target service identifier on the service operation object according to the target service operation value and the target value type, the calling response data fed back by the second service end is received, and the calling response data is sent to the client. According to the embodiments of the present disclosure, the same general service interface can be called by changing the service operation object and the target service identifier, so as to implement different service functions on different operation objects, thereby avoiding the problem that the service function code and the service interface need to be newly added or modified every time the service function is newly added or modified. Not only the number of service interfaces can be reduced, but also the service interface management efficiency can be improved, the code development workload can be greatly reduced, the service maintenance cost can be saved, and the development efficiency can be improved.
[0082] In some embodiments of the present disclosure, in the case of data processing on a database, the service operation object is a storage object in the database, and the preset service function includes at least one of an object assignment function, a value deletion function, a value accumulation function, a first value insertion function, a second value insertion function, a first numerical value update function, and a second numerical value update function.
[0083] Specifically, in the scenario of data processing on a database, the service operation object is a storage object in the database, such as a field object in a document database. The storage object can be an existing object or a newly created object.
[0084] In the same scenario, the preset service function can include service functions such as data storage, data reading, data updating, and the like on the database. Specifically, the preset service function can include at least one of an object assignment function, a value deletion function, a value accumulation function, a first value insertion function, a second value insertion function, a first numerical value updating function, and a second numerical value updating function.
[0085] Exemplarily, the preset service function can be implemented through the following code:
[0086] enum StudyDataOperation {
[0087] Upsert = 1 / / object assignment function
[0088] Delete = 2 / / value deletion function
[0089] Inc = 3 / / value accumulation function
[0090] Push = 4 / / first value insertion function
[0091] AddSet = 5 / / second value insertion function
[0092] GAU = 6 / / first numerical value updating function, updating value is greater than stored object value
[0093] LAU = 7 / / second numerical value updating function, updating value is less than stored object value
[0094] }.
[0095] The object assignment function is used to replace the field value of the storage object with the target service operation value when the field value exists, or to assign the target service operation value to the storage object when the field value does not exist. The value deletion function is used to delete the storage object corresponding to the target service operation value when the storage object exists, or to do nothing when the storage object does not exist. The value accumulation function is used to accumulate the field value of the storage object with the target service operation value when the field value exists, or to directly assign the target service operation value to the storage object when the field value does not exist. The first value insertion function is used to insert the target service operation value into a container (such as a queue) corresponding to the storage object in sequence. The second value insertion function is used to insert the target service operation value into the container when the target service operation value does not exist in the container. The first numerical value update function (greate and update) is used to update the field value of the storage object with the target service operation value when the target service operation value is greater than the field value, and only supports integer Int data types and floating point Float data types. The second numerical value update function (less and update) is used to update the field value of the storage object with the target service operation value when the target service operation value is less than the field value, and only supports integer Int data types and floating point Float data types.
[0096] In some embodiments of the present disclosure, the database is a document database.
[0097] The document database is also referred to as a document-oriented database or a document store, which refers to a database that stores information in documents, and is a type of non-relational database, such as a MongoDB database.
[0098] The advantages of such a setting are as follows. On the one hand, the document database can support field-granularity modification without the need to parse a complete data structure. For example, in a teaching scenario, when it is necessary to perform corresponding operations on the answering time and score of a student, the answering time field and the score field can be extracted from the student data table to obtain a service operation object, without the need to extract the complete student data table, thereby improving data access rate. On the other hand, the general service interface provided in the embodiments of the present disclosure is compatible with multiple service functions, and the data structure types corresponding to different service functions can be diversified. Thus, when different data structure types are stored, data structure conversion needs to be repeatedly performed. However, the document database can store data in a field-granularity manner during data storage, thereby avoiding frequent data structure conversion and reducing the amount of modification during data storage.
[0099] Based on the above description of the service calling system, the embodiments of the present disclosure further provide a service calling method applied to a second service end. The service calling method applied to the second service end can be applied to the calling between services in the server backend, for example, can be applied to the data processing in the online teaching scene, and can also be applied to the data access scene of live streaming or video streaming, etc. The method can be executed by a service calling device configured in the second service end. The device can be realized by software and / or hardware, and the device can be integrated in the electronic device corresponding to the second service end. The electronic device can include but is not limited to notebook computers, desktop computers, servers or server clusters, etc.
[0100] Figure 3 A flowchart of a service calling method applied to a second service end provided by the embodiments of the present disclosure is shown. Referring to FIG. 4, Figure 3 The service calling method applied to the second service end includes:
[0101] S301, receiving a second service calling request sent by a first service end.
[0102] The second service calling request is generated based on a service operation object, a target service identifier, a target service operation value, a target value type and a general service interface included in the first service calling request; and the first service calling request is sent by a client to the first service end.
[0103] The second service calling request refers to a general service interface calling request generated by the first service end for remote calling of the first service request, so that the second service end can operate according to the request.
[0104] In the embodiments of the present disclosure, after receiving the second service calling request sent by the first service end, the second service end determines the interface calling parameters through the service interface based on the second service calling request.
[0105] S302, based on the target service operation value and the target value type, performing a preset service function corresponding to the target service identifier on the service operation object to generate a calling response data.
[0106] The target service operation value can be obtained based on the field corresponding to the target value type.
[0107] Specifically, after receiving the second service calling request, the second service end parses the corresponding parameters, i.e. the service operation object, the target service identifier, the target service operation value and the target value type based on the second service calling request, then performs a preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type, and finally generates a calling response data.
[0108] S203, send the invocation response data to the first server.
[0109] In the embodiments of the present disclosure, the data obtained by executing the preset service function corresponding to the target service identifier based on the service operation object, the target service operation value and the target value type is taken as the invocation response data, and the invocation response data is sent to the first server.
[0110] In the service invocation method provided by the embodiments of the present disclosure, the second service invocation request sent by the first server is received; wherein the second service invocation request is generated based on the service operation object, the target service identifier, the target service operation value and the target value type and the general service interface contained in the first service invocation request; the first service invocation request is sent by the client to the first server, the preset service function corresponding to the target service identifier is executed on the service operation object based on the target service operation value and the target value type, the invocation response data is generated, and the invocation response data is sent to the first server. In the embodiments of the present disclosure, different service functions are realized on different operation objects based on the same general service interface. In the service invocation process, only the service operation object and the target service identifier need to be modified, and no other service interface needs to be added, thereby saving the service maintenance cost and improving the development efficiency.
[0111] In some embodiments of the present disclosure, the storage structure of the target service operation value and the target value type is a preset structure body.
[0112] The preset structure body refers to a predefined structure body type.
[0113] Specifically, the target value type can be defined as the following preset structure body:
[0114]
[0115]
[0116] The storage structure of the target service operation value can be defined as the following preset structure body:
[0117] struct StudyDataValue{
[0118] 1: StudyDataValueType Type / / target value type, the target service operation value is obtained from the following fields according to the target value type
[0119] 2: optional string StrVal / / string is a string type, StrVal is a specific value
[0120] 3: optional int IntVal / / int is an integer type, IntVal is a specific value
[0121] 4: optional float FloatVal / / float is single precision floating point type, FloatVal is specific value
[0122] 5: optional array ArrVal / / array is array type, ArrVal is specific value
[0123] 6: optional object ObjVal / / object is object type, ObjVal is specific value
[0124] }.
[0125] Correspondingly, S302 can be implemented as steps A-C as follows:
[0126] Step A, obtaining the numerical value corresponding to the target value type from the preset structure as the target service operation value.
[0127] Specifically, in the embodiments of the present disclosure, after determining the target value type Type, the target service operation value is obtained according to the target value type Type from the preset structure StudyDataValue of the target service operation value. For example, if the target value type is float, the value FloatVal can be read from the preset structure StudyDataValue of the target service operation value as the target service operation value. In this way, the reading accuracy of the target service operation value can be improved.
[0128] Step B, determining the target service processing function corresponding to the target service identifier from the function mapping relationship.
[0129] The function mapping relationship is used to record the corresponding relationship between the preset service identifier and the preset service processing function. The preset service identifier is identification information used to describe the preset service function, which can be the full name, abbreviation, number, etc. of the preset service function. The preset service processing function is a function for executing the preset service function. In order to facilitate service searching, the function mapping relationship is set in the embodiments of the present disclosure, which can be set as an enumeration structure type, or a table or array recording the corresponding relationship, etc.
[0130] Specifically, the second service end parses the target service identifier according to the second service invocation request after receiving the second service invocation request sent by the first service end. Then, the target service processing function corresponding to the target service identifier is obtained according to the target service identifier and the function mapping relationship. For example, when the target service identifier is a value deletion function identifier (such as Delete or 2), the target service processing function Delete can be obtained through the enumeration structure type StudyDataOperation in the above embodiment.
[0131] Step C, based on the target service operation value, calling the target service processing function of the service operation object to execute the preset service function corresponding to the target service identifier on the service operation object, and generating the calling response data.
[0132] Specifically, the second service end calls the target service processing function of the service operation object with the target service operation value as an input parameter. Through the execution of the target service processing function, the preset service function corresponding to the target service identifier can be executed on the service operation object, and the calling response data is obtained.
[0133] In some embodiments of the present disclosure, in the case of data processing on a database and the database being a document database, the second service invocation request further includes a first object version identifier.
[0134] The first object version identifier is used to identify the operation version of the service operation object in the second service invocation request, for example, it can be a version number composed of at least information such as letters, numbers, special symbols, etc., which is used to identify the processing progress of the service operation object.
[0135] Specifically, in order to avoid the processing conflict problem of concurrent invocation and the problem that the document database does not support transaction data processing, the first object version identifier is set for each service operation object in the embodiment, and the first object version identifier is updated with each service operation of the service operation object.
[0136] Correspondingly, before the second service end executes the preset service function corresponding to the target service identifier on the service operation object, if it is determined that the first object version identifier is consistent with a second object version identifier of the service operation object stored in the document database, the execution of S302 is triggered.
[0137] The second object version identifier is used to identify the version number of the service operation object stored in the document database.
[0138] In an alternative implementation, if the first object version identifier and the second object version identifier are the same, it indicates that the service operation object is not updated, and at this time, the step of executing the preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type to generate the invocation response data can be triggered.
[0139] In another alternative implementation, if the first object version identifier and the second object version identifier are different, it indicates that the service operation object is updated, and at this time, the second service invocation request is terminated.
[0140] In addition, in order to ensure the accuracy of the service operation object, after the service operation object executes the preset service function corresponding to the target service identifier based on the target service operation value and the target value type, the second object version identifier is updated, and the updated second object version identifier is not repeated with each historical second object version identifier.
[0141] In the embodiments of the present disclosure, it is assumed that G and H simultaneously perform different operations on the service operation object I. After I performs a certain operation on the service operation object I, the second object version identifier corresponding to the service object I will be updated, and the updated second version identifier is not repeated with each historical second object version identifier. Since the second object version identifier of the service operation object I has changed, I cannot perform the corresponding operation on the service operation object I at this time, which ensures the accuracy of the data when the database is processed.
[0142] Based on the above judgment and update of the service operation object version number, the lack of not supporting transactions in the case of a document database is made up, and the data access rate is improved.
[0143] Figure 4 A structure diagram of a service invocation device configured on a first service end is shown. As shown in Figure 4 The service invocation device can include:
[0144] The interface invocation parameter determination module 401 is configured to receive a first service invocation request sent by a client, and determine an interface invocation parameter of a general service interface based on the service invocation request. The interface invocation parameter includes a service operation object, a target service identifier, a target service operation value, and a target value type.
[0145] The second service invocation request sending module 402 is configured to send a second service invocation request to a second service end based on the interface invocation parameter and the general service interface, so that the second service end executes a preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type.
[0146] The calling response data receiving module 403 is configured to receive calling response data fed back by the second server, and send the calling response data to the client.
[0147] The service calling device configured on the first server provided by the embodiments of the present disclosure can call the same general service interface by changing the service operation object and the target service identifier, so as to implement different service functions on different operation objects, thereby avoiding the problem that the service function code and the service interface need to be added or modified every time the service function is added or modified, reducing the number of service interfaces, improving the service interface management efficiency, greatly reducing the code development workload, saving the service maintenance cost, and improving the development efficiency. In an optional implementation, in the case of data processing on the database, the service operation object is a storage object in the database, and the preset service function includes at least one of an object assignment function, a value deletion function, a value accumulation function, a first value insertion function, a second value insertion function, a first numerical value update function, and a second numerical value update function.
[0148] In an optional implementation, the database is a document database.
[0149] The service calling device configured on the first server provided by the embodiments of the present disclosure can execute the service calling method applied to the first server provided by any of the embodiments of the present disclosure, and has the corresponding function modules and beneficial effects of the execution method.
[0150] The embodiments of the present disclosure also provide a service calling device configured on a second server, as shown in Figure 5 The service calling device configured on the second server provided by the embodiments of the present disclosure can execute the service calling method applied to the second server provided by any of the embodiments of the present disclosure, and has the corresponding function modules and beneficial effects of the execution method.
[0151] The second service calling request receiving module 501 is configured to receive a second service calling request sent by the first server; wherein the second service calling request is generated based on a service operation object, a target service identifier, a target service operation value, and a target value type contained in a first service calling request, and a general service interface; the first service calling request is sent by a client to the first server;
[0152] The calling response data generating module 502 is configured to execute a preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type, and generate calling response data;
[0153] The calling response data sending module 503 is configured to send the calling response data to the first server.
[0154] The service calling device configured on the second service end provided by the embodiment of the present disclosure can implement different service functions on different operation objects based on the same general service interface, and only the service operation object and the target service identifier need to be modified in the service calling process, without the need to add other service interfaces, thereby saving service maintenance cost and improving development efficiency.
[0155] In an optional implementation, the storage structure of the target service operation value and the target value type is a preset structure body, and the calling response data generation module comprises:
[0156] A target value type acquisition submodule is configured to acquire a numerical value corresponding to the target value type from the preset structure body as the target service operation value.
[0157] A target service processing function determination submodule is configured to determine a target service processing function corresponding to the target service identifier from a function mapping relationship, wherein the function mapping relationship is configured to record a corresponding relationship between a preset service identifier and a preset service processing function, and the preset service processing function is a function for executing a preset service function.
[0158] A calling response data generation submodule is configured to execute the target service processing function of the service operation object based on the target service operation value, to execute the preset service function corresponding to the target service identifier on the service operation object, and to generate the calling response data.
[0159] In an optional implementation, in the case of data processing on a database and the database being a document database, the second service calling request further comprises a first object version identifier; and before the calling response data generation module, the device further comprises:
[0160] An identifier consistency confirmation module is configured to, if it is determined that the first object version identifier is consistent with a second object version identifier of the service operation object stored in the document database, trigger the execution of the step of executing the preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type, and generating the calling response data.
[0161] After the calling response data generation module, the device further comprises:
[0162] A second object version identifier updating module is configured to update the second object version identifier, and the updated second object version identifier is not repeated with each historical second object version identifier.
[0163] The service calling apparatus configured at the second service end provided by the embodiments of the present disclosure can execute the service calling method applied to the second service end provided by any of the embodiments of the present disclosure, and has the function modules and beneficial effects corresponding to the execution method.
[0164] It is worth noting that in each of the above embodiments of the service calling apparatus configured at the first service end and the service calling apparatus configured at the second service end, each module included is only divided according to the function logic, but is not limited to the above division, as long as the corresponding function can be realized; in addition, the specific name of each function module is only for the convenience of mutual differentiation, and does not serve to limit the protection scope of the present disclosure.
[0165] The embodiments of the present disclosure further provide an electronic device, which can include a processor and a memory. The memory can be configured to store executable instructions. The processor can be configured to read the executable instructions from the memory and execute the executable instructions to implement the service calling method in the above embodiments.
[0166] Figure 6 A structural schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown.
[0167] As shown in Figure 6 The electronic device 600 can include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 602 or programs loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the information processing device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output interface (I / O interface) 605 is also connected to the bus 604.
[0168] Generally, the following devices can be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 can allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data.
[0169] It should be noted that Figure 6 The electronic device 600 shown is only an example and should not impose any limitation on the functions and use range of the embodiments of the present disclosure. That is, although Figure 6The electronic device 600 is illustrated with various means, but it is understood that not all of the illustrated means need be present in order to practice or have the electronic device. More or less means can alternatively be present.
[0170] In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from the network by the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the service invocation method of any embodiment of the present disclosure are executed.
[0171] Embodiments of the present disclosure also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to implement the service invocation method in any embodiment of the present disclosure.
[0172] It should be noted that the computer readable medium in the above disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer readable storage medium may, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this disclosure, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus or device. In this disclosure, the computer readable signal medium can include a data signal carried in a baseband or as part of a carrier wave, which carries computer readable program code. Such a propagated data signal can take many forms, including but not limited to, an electromagnetic signal, an optical signal or any suitable combination of the above. The computer readable signal medium can also be any computer readable medium that can send, propagate or transmit the program for use by or in connection with an instruction execution system, apparatus or device. The program code contained on the computer readable medium can be transmitted by any suitable medium, including but not limited to, wire, cable, RF (radio frequency), etc., or any suitable combination of the above.
[0173] In some embodiments, the client, server can communicate using any currently known or future developed network protocol, such as HTTP, and can be interconnected with any form or medium of digital data communication (e.g., communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet, and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
[0174] The computer readable medium described above can be included in the electronic device described above; or can exist separately from the electronic device and not be assembled into the electronic device.
[0175] The computer readable medium described above carries one or more programs, when the one or more programs are executed by the electronic device, cause the electronic device to perform the steps of the service calling method described in any embodiment of the disclosure.
[0176] Computer program code for carrying out operations of the present disclosure can be written in any one or more of a variety of programming languages or combinations of languages including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages such as C or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0177] The computer program instructions can also be loaded onto a computer or other programmable information processing apparatus to cause a series of operations to be performed on the computer or other programmable information processing apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable information processing apparatus implement the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0178] The functions described herein above can be performed, at least in part, by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Program-specific Integrated Circuits (ASICs), Program-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.
[0179] In the context of this disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include a lined- up electrical connection, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0180] The above description is only preferred embodiments of the present disclosure and the explanation of the applied technical principles. It should be understood by those skilled in the art that the disclosure range involved in the present disclosure is not limited to the technical solutions formed by the specific combinations of the above technical features, and also covers other technical solutions formed by any combination of the above technical features or equivalent features without departing from the above disclosed concept. For example, the technical solutions formed by replacing the above features with the technical features disclosed in the present disclosure (but not limited to) having similar functions.
[0181] In addition, although each operation is described in a particular order, this should not be understood as requiring the operations to be performed in the specific order shown or in a sequential order. In certain circumstances, multitasking and parallel processing can be advantageous. Similarly, although several implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments can also be combined in a single embodiment. Conversely, various features described in the context of a single embodiment can also be separated and implemented in multiple embodiments.
[0182] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.
Claims
1. A service invocation method, characterized by, Applied to a first service end, comprising: Receiving a first service call request sent by a client, and determining that the first service call request corresponds to a preset service function, and determining the interface call parameters of the general service interface corresponding to the preset service function based on the first service call request; wherein the general service interface is an interface definition and an interface parameter fixed, and internally pre-integrated with a plurality of service interfaces of the preset service function; the interface call parameters include service operation objects, target service identifiers, target service operation values and target value types; Based on the interface call parameters and the general service interface, a second service call request is sent to a second service end, so that the second service end executes the preset service function corresponding to the target service identifier on the service operation object according to the target service operation value and the target value type; Receiving the call response data fed back by the second service end, and sending the call response data to the client.
2. The method of claim 1, wherein, In the case of data processing on the database, the service operation object is a storage object in the database, and the preset service function includes at least one of object assignment function, value deletion function, value accumulation function, first value insertion function, second value insertion function, first numerical value update function and second numerical value update function.
3. The method of claim 2, wherein, The database is a document database.
4. A service invocation method characterized by, Applied to a second service end, comprising: Receiving a second service call request sent by a first service end; wherein the second service call request is generated by the first service end based on the interface call parameters contained in the first service call request and the general service interface corresponding to the preset service function when determining that the first service call request corresponds to the preset service function; the first service call request is sent by a client to the first service end; the general service interface is an interface definition and an interface parameter fixed, and internally pre-integrated with a plurality of service interfaces of the preset service function; the interface call parameters include service operation objects, target service identifiers, target service operation values and target value types; Based on the target service operation value and the target value type, the preset service function corresponding to the target service identifier is executed on the service operation object to generate call response data; Sending the call response data to the first service end.
5. The method of claim 4, wherein, The storage structure of the target service operation value and the target value type is a preset structure; The target value type corresponding to the target value type is obtained from the preset structure as the target service operation value; Determining the target service processing function corresponding to the target service identifier from the function mapping relationship; wherein the function mapping relationship is used to record the corresponding relationship between the preset service identifier and the preset service processing function; the preset service processing function is a function for executing the preset service function; Based on the target service operation value, the target service processing function of the service operation object is called to execute the target service identification corresponding preset service function on the service operation object, and the calling response data is generated.
6. The method of claim 4, wherein, In the case of data processing on the database, and the database is a document database, the first object version identifier is further included in the second service calling request; Before the step of executing the target service identification corresponding preset service function on the service operation object based on the target service operation value and the target value type, and generating the calling response data, the method further comprises: If it is determined that the first object version identifier is consistent with the second object version identifier of the service operation object stored in the document database, the step of executing the target service identification corresponding preset service function on the service operation object based on the target service operation value and the target value type, and generating the calling response data is triggered. After the step of executing the target service identification corresponding preset service function on the service operation object based on the target service operation value and the target value type, and generating the calling response data, the method further comprises: Updating the second object version identifier, and the updated second object version identifier is not repeated with each historical second object version identifier.
7. A service invocation apparatus characterized by comprising: Configured in the first service end, comprising: The interface calling parameter determination module is configured to receive a first service calling request sent by a client, and determine the interface calling parameter of a general service interface corresponding to a preset service function based on the service calling request when the first service calling request corresponds to the preset service function. The general service interface is an interface definition and an interface parameter fixed, and internally pre-integrated with a plurality of service interfaces of the preset service function. The interface calling parameter includes a service operation object, a target service identifier, a target service operation value and a target value type. The second service calling request sending module is applied to send a second service calling request to a second service end based on the interface calling parameter and the general service interface, so that the second service end executes the target service identification corresponding preset service function on the service operation object according to the target service operation value and the target value type. The calling response data receiving module is configured to receive the calling response data fed back by the second service end, and send the calling response data to the client.
8. A service invocation apparatus characterized by comprising: Configured in the second service end, comprising: The second service call request receiving module is configured to receive a second service call request sent by the first service end; wherein the second service call request is generated by the first service end based on an interface call parameter contained in a first service call request and a general service interface corresponding to a preset service function when the first service end determines that the first service call request corresponds to the preset service function; the first service call request is sent by a client to the first service end; the general service interface is an interface definition and an interface parameter fixed, and internally pre-integrated with service interfaces of a plurality of preset service functions; and the interface call parameter includes a service operation object, a target service identifier, a target service operation value, and a target value type. The call response data generating module is configured to execute the preset service function corresponding to the target service identifier on the service operation object based on the target service operation value and the target value type, and generate call response data. The call response data sending module is configured to send the call response data to the first service end.
9. An electronic device, comprising: The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the service call method in any one of claims 1-6. The storage medium stores a computer program, and when the computer program is executed by the processor, the processor implements the service call method in any one of claims 1-6. 10. A computer-readable storage medium, characterized in that,
Citation Information
Patent Citations
Data calling method and device and electronic equipment
CN111930534A
Service calling method and device, storage medium and electronic equipment
CN113806037A