Search

CN-117407460-B - Cross-environment data synchronization method and device, storage medium and electronic equipment

CN117407460BCN 117407460 BCN117407460 BCN 117407460BCN-117407460-B

Abstract

The application discloses a cross-environment data synchronization method, a device, a storage medium and electronic equipment, which relate to the technical field of computers, wherein the cross-environment data synchronization method is applied to a first synchronization service deployed in a first environment, and the first synchronization service can execute the cross-environment data synchronization method; according to the callback environment address, a reading interface is called to send a reading request to a second synchronous service deployed in a second environment, the reading request carries a synchronous code and an authorization value corresponding to a data application record, the synchronous code and the authorization value are generated and recorded when indication information indicates authorization, the synchronous request sent by a second synchronous service calling and writing interface is received, the synchronous request comprises the synchronous code and synchronous data, if the synchronous code passes through verification, the synchronous data is stored, and the authorization value is updated to be the synchronous value. The application can safely improve the synchronization efficiency and reliability when data synchronization is performed across environments.

Inventors

  • CHEN HONG

Assignees

  • 深圳TCL新技术有限公司

Dates

Publication Date
20260512
Application Date
20230410

Claims (10)

  1. 1. A method of cross-environment data synchronization, for application to a first synchronization service deployed in a first environment, the method comprising: Receiving an authorization request sent by a first foreground service call authorization interface, wherein the authorization request carries indication information of a data application record, the data application record is derived from a second environment, and the data application record comprises a data identifier, a callback address of the second environment and a target address of the first environment; According to the callback address, a reading interface is called to send a reading request to a second synchronous service deployed in the second environment, the reading request carries a synchronous code and an authorization value corresponding to the data application record, and the synchronous code and the authorization value are generated and recorded when the indication information indicates authorization; Receiving a synchronization request sent by a second synchronization service calling writing interface, wherein the synchronization request comprises the synchronization code and synchronization data corresponding to the data identifier, and the writing interface is called according to the target address when the second synchronization service determines that the authorization value characterizes authorization; And if the received synchronization code passes the verification, storing the synchronization data, and updating the authorization value into a synchronization value, wherein the synchronization value is used for indicating that the synchronization is successful.
  2. 2. The method of claim 1, wherein prior to said receiving an authorization request sent by a first foreground service invocation authorization interface, the method further comprises: receiving a query request sent by the first foreground service call application record query interface; and responding to the query request, and sending a data synchronization application record in the first environment to the first foreground service, wherein the data synchronization application record comprises the data application record.
  3. 3. The method of claim 1, wherein prior to receiving the authorization request sent by the foreground service invocation authorization interface, the method further comprises: Receiving a synchronous application request sent by the second synchronous service call synchronous application interface, wherein the synchronous application request carries the data application record; and writing the data application record into a database, and returning a writing success message to the second synchronous service so as to trigger the second synchronous service to generate and record a writing value according to the writing success message, wherein the writing value is used for indicating writing success.
  4. 4. The method of claim 1, wherein the second synchronization service generates and records a record value corresponding to the data application record when the authorization value characterizes authorization, the record value being used for recording authorized, and wherein after the updating the authorization value to the synchronization value, the method further comprises: Sending indication information of successful synchronization to a second synchronization service to trigger the second synchronization service to update the recorded value to the synchronization value; receiving a synchronization message returned by the second synchronization service, wherein the synchronization message is used for indicating that the synchronization of the synchronization value is successful; and responding to the synchronization message, and sending a result message to the first foreground service, wherein the result message is used for indicating that the data synchronization corresponding to the data application record is completed.
  5. 5. The method of claim 1, wherein the indication information includes authorization operation information, an authorizer account number and an authorization time recorded for a target application in the first foreground service, wherein the synchronization code and the authorization value are generated and recorded when the authorization operation information is authorized; The reading request further comprises the authorizer account number and the authorization time, and the authorizer account number and the authorization time are associated with the data application record in the second synchronous service.
  6. 6. The method of claim 1, wherein prior to receiving the authorization request sent by the foreground service invocation authorization interface, the method further comprises: Acquiring the first synchronous service, wherein the first synchronous service is the same data synchronous service as the second synchronous service; the first synchronization service is deployed in the first environment.
  7. 7. The method of claim 1, wherein prior to storing the synchronization data if the synchronization code received is verified to pass, the method further comprises: comparing whether the received synchronization code is the same as the recorded synchronization code; and if the synchronous codes are the same, checking that the received synchronous codes pass.
  8. 8. A cross-environment data synchronization apparatus for application to a first synchronization service deployed in a first environment, the apparatus comprising: the instruction information receiving module is used for receiving an authorization request sent by the first foreground service call authorization interface, wherein the authorization request carries instruction information of a data application record, the data application record is derived from a second environment, and the data application record comprises a data identifier, a callback address of the second environment and a target address of the first environment; A read request sending module, configured to invoke a read interface to send a read request to a second synchronization service deployed in the second environment according to the callback address, where the read request carries a synchronization code and an authorization value corresponding to the data application record, and the synchronization code and the authorization value are generated and recorded when the indication information indicates authorization; The synchronous request receiving module is used for receiving a synchronous request sent by the second synchronous service calling writing interface, the synchronous request comprises the synchronous code and synchronous data corresponding to the data identifier, and the writing interface is called according to the target address when the second synchronous service determines that the authorization value characterizes authorization; And the synchronization updating module is used for storing the synchronization data and updating the authorization value into a synchronization value if the received synchronization code passes verification, wherein the synchronization value is used for indicating successful synchronization.
  9. 9. A storage medium having stored thereon a computer program which, when executed by a processor of a computer, causes the computer to perform the method of any of claims 1 to 7.
  10. 10. An electronic device comprising a memory storing a computer program, and a processor reading the computer program stored in the memory to perform the method of any one of claims 1 to 7.

Description

Cross-environment data synchronization method and device, storage medium and electronic equipment Technical Field The present application relates to the field of computer technologies, and in particular, to a cross-environment data synchronization method, apparatus, storage medium, and electronic device. Background In many scenarios, for example, in a software development process, there is a need to perform cross-environment data synchronization among a development environment, a test environment, a pre-release environment, and a production environment. At present, the scheme of cross-environment data synchronization is generally that cross-environment data synchronization is carried out by generating sql sentences through manpower or programs, the operation is complicated, the data synchronization efficiency is low, unreliable factors in the process are more, such as data omission, table field misalignment and the like, and problems in the data synchronization process often lead to data synchronization failure and a large number of rollback operations are needed. In the current mode, the cross-environment data synchronization has the problems of low synchronization efficiency and poor synchronization reliability, and the security is difficult to be ensured in the synchronization process. Disclosure of Invention The embodiment of the application provides a scheme which can safely improve the synchronization efficiency and reliability when data synchronization is performed across environments. The embodiment of the application provides the following technical scheme: According to the callback environment address, a reading interface is called to send a reading request to a second synchronous service deployed in the second environment, the reading request carries a synchronous code and an authorization value corresponding to the data application record, the synchronous code and the authorization value are generated and recorded when the indication information indicates authorization, the synchronous request sent by a second synchronous service call writing interface is received, the synchronous request comprises the synchronous code and synchronous data corresponding to the data identification, the writing interface characterizes the second synchronous service according to the target address when the authorization value is determined to be authorized, and if the synchronous code and the synchronization value are verified to be successful, the synchronous code and the authorization value are stored, and the synchronous value is used for indicating that the synchronous code and the synchronization value are more successful. In some embodiments of the present application, before the receiving the authorization request sent by the first foreground service invocation authorization interface, the method further includes receiving a query request sent by the first foreground service invocation application record query interface, and sending a data synchronization application record in the first environment to the first foreground service in response to the query request, where the data synchronization application record includes the data application record. In some embodiments of the present application, before the receiving the authorization request sent by the foreground service invoking authorization interface, the method further includes receiving a synchronization application request sent by the second synchronization service invoking synchronization application interface, where the synchronization application request carries the data application record, writing the data application record into a database, and returning a writing success message to the second synchronization service, so as to trigger the second synchronization service to generate and record a writing value according to the writing success message, where the writing value is used to indicate that the writing is successful. In some embodiments of the present application, the second synchronization service generates and records a record value corresponding to the data application record when the authorization value characterizes authorization, the record value is used for recording authorization, after the authorization value is updated to be the synchronization value, the method further includes sending information indicating that synchronization is successful to the second synchronization service to trigger the second synchronization service to update the record value to be the synchronization value, receiving a synchronization message returned by the second synchronization service, the synchronization message is used for indicating that synchronization of the synchronization value is successful, and sending a result message to the first foreground service in response to the synchronization message, wherein the result message user indicates that data synchronization corresponding to the data application record is completed. In some embodiments o