CN-122022789-A - Service identifier generating device, method, electronic equipment and storage medium
Abstract
The present application relates to the field of computer technologies, and in particular, to a service identifier generating device, a service identifier generating method, an electronic device, and a storage medium. The method is used for solving the problem of disordered service identification in the current Internet service, and a reasonable service identification generation scheme is provided on the global service level. The application provides a service identifier generating device, which performs overall planning on the generation of service identifiers at the global service level. The service identifier generating device specifically comprises a primary identifier generating module, an identifier distributing module and a service identifier generating module. The communication cooperation can be carried out among the modules to complete the generation of the service identification. In actual working, service conditions are often complex, the service identifier generating device with a single structure has poor flexibility, and the requirement of each sub-service module in the whole service is difficult to meet. The functional modules in the service identifier generating device provided by the application can flexibly select the deployment positions according to the needs so as to support the needs of different deployment scenes.
Inventors
- Shu Huhong
- HE GUOXING
Assignees
- 顺丰恒通支付有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20241108
Claims (10)
- 1. A service identifier generating device, comprising: The system comprises a primary identifier generation module, an identifier distribution module and a service identifier generation module; the primary identification generation module is used for receiving a primary identification generation request sent by the identification distribution module, selecting a corresponding primary identification generation mode according to the primary identification generation request, and generating and returning a primary identification corresponding to the primary identification generation request, wherein the primary identification generation mode comprises a database generation mode for generating the primary identification by using a database and/or a distributed node generation mode for generating the primary identification by using a distributed node; The identification distribution module is used for generating and sending the primary identification generation request to the primary identification generation module when the primary identification needs to be acquired; receiving a primary identifier corresponding to the primary identifier generation request returned by the primary identifier generation module and sending the primary identifier to the service identifier generation module; the service identifier generating module is used for receiving the primary identifier sent by the identifier distributing module and generating a service identifier according to a preset service identifier generating rule and the primary identifier.
- 2. The service identification generation device according to claim 1, wherein the primary identification generation module is further configured to: Storing the time stamp of the generation time of the primary identifier as a heartbeat time stamp; And when a refresh command sent by the identification distribution module is received, updating the heartbeat time stamp with the time stamp of the moment of receiving the refresh command according to the refresh command.
- 3. The service identifier generating device according to claim 2, wherein the primary identifier generating module is configured to: Receiving a first-level identification generation request sent by the identification distribution module; selecting a corresponding primary identification generation mode according to the primary identification generation request; When the number of the first-level identifiers reaches an upper limit, acquiring heartbeat time stamps of all the first-level identifiers in the corresponding first-level identifier generation mode; Calculating interval duration between heartbeat time stamps of all the primary identifiers and the current time, selecting one primary identifier with the interval duration longer than a first preset duration as the primary identifier corresponding to the primary identifier generation request, and returning.
- 4. The service identification generation apparatus of claim 3, wherein the primary identification generation module is configured to: Selecting an unoccupied distributed node from a service identification node cluster as a service identification node corresponding to the primary identification generation request; Generating and returning a primary identifier corresponding to the primary identifier request according to the name of the service identifier node; The primary identification generation module is further configured to: and storing the time stamp of the generation time of the primary identifier in the service identifier node as a heartbeat time stamp.
- 5. The service identification generation apparatus of claim 3, wherein the primary identification generation module is configured to: Inquiring a primary identification field in a service identification table, selecting an unoccupied primary identification within a preset range according to an inquiry result as the primary identification corresponding to the primary identification request, and storing the primary identification into the service identification table; The primary identification generation module is further configured to: And storing the time stamp of the generation time of the primary identifier in a time stamp field of the service identifier table as a heartbeat time stamp.
- 6. The service identification generation device according to claim 1, wherein the identification distribution module is further configured to: and sending a refreshing instruction to the primary identification generating module to instruct the primary identification generating module to update the heartbeat time stamp.
- 7. The service identification generation apparatus of claim 6, wherein the identification distribution module is further configured to: After sending a refreshing instruction to the primary identifier generating module, comparing the heartbeat time stamp stored in the identifier distributing module with the heartbeat time stamp stored in the primary identifier generating module before the primary identifier generating module updates the heartbeat time stamp; when the comparison result shows that the two heartbeat time stamps are different, generating and sending a new primary identification generation request to the primary identification generation module; Receiving a new primary identifier corresponding to the new primary identifier generation request returned by the primary identifier generation module and sending the new primary identifier to the service identifier generation module; And locking the service identifier generating module until the service identifier generating module uses the new primary identifier to generate a new service identifier.
- 8. A method for generating a service identifier, comprising: when the primary identifier needs to be acquired, the identifier distribution module generates and sends a primary identifier generation request to the primary identifier generation module; The primary identifier generation module receives the primary identifier generation request sent by the identifier distribution module, selects a corresponding primary identifier generation mode according to the primary identifier generation request, and generates and returns a primary identifier corresponding to the primary identifier generation request, wherein the primary identifier generation mode comprises a database generation mode for generating the primary identifier by using a database and/or a distributed node generation mode for generating the primary identifier by using a distributed node; The identifier distribution module receives a first-level identifier corresponding to the first-level identifier generation request returned by the first-level identifier generation module and sends the first-level identifier to the service identifier generation module; The service identifier generating module receives the primary identifier sent by the identifier distributing module and generates a service identifier according to a preset service identifier generating rule and the primary identifier.
- 9. An electronic device comprising a memory and a processor; the memory is connected with the processor and used for storing programs; The processor is configured to implement the service identifier generating method according to claim 8 by running a program in the memory.
- 10. A storage medium having stored thereon a computer program which, when executed by a processor, implements the service identification generation method of claim 8.
Description
Service identifier generating device, method, electronic equipment and storage medium Technical Field The present application relates to the field of computer technologies, and in particular, to a service identifier generating device, a service identifier generating method, an electronic device, and a storage medium. Background In the internet service, for a service with a larger scale, the service is generally further divided into a plurality of sub-services, and the sub-services are delivered to different technicians for development. For example, for a payment service, links of generating a payment transaction order, an authentication order, a channel flow, a charging order and the like in the payment service are divided into different sub-service modules, and then the sub-services are respectively developed by different technicians. In the development work, because developers of the respective sub-services are different, a problem of repeated development often occurs, for example, each sub-service has embedded therein an identifier generation service in the sub-service for generating data identifiers, such as generating transaction order numbers and authentication order numbers. When the services are operated as a whole, the sub-services repeatedly call the identification generation service embedded in the sub-services. The logic of implementation of these separately developed identity generation services is very similar, which in effect creates the problem of "re-creating wheels" and adds unnecessary development costs. And because the parameters configured in each generated identifier service are different, the concurrency capability of each identifier generated service is also uneven, and problems are easy to occur when each sub-service module is in butt joint. Therefore, a global identifier generation service is needed at present, which is used for reasonably and comprehensively planning the service identifiers related to the whole service. Disclosure of Invention In view of this, the present application is directed to providing a service identifier generating device, method, electronic device and storage medium, which are used to solve the problem of confusion of service identifiers in the current internet service, and provide a service identifier generating scheme with reasonable planning at the global service level. The embodiment of the application provides a service identifier generating device which comprises a first-level identifier generating module, an identifier distributing module and a service identifier generating module, wherein the first-level identifier generating module is used for receiving a first-level identifier generating request sent by the identifier distributing module, selecting a corresponding first-level identifier generating mode according to the first-level identifier generating request, generating and returning a first-level identifier corresponding to the first-level identifier generating request, the first-level identifier generating mode comprises a database generating mode for generating the first-level identifier by using a database and/or a distributed node generating mode for generating the first-level identifier by using a distributed node, the identifier distributing module is used for generating and sending the first-level identifier generating request to the first-level identifier generating module when the first-level identifier is required to be acquired, receiving the first-level identifier corresponding to the first-level identifier generating request returned by the first-level identifier generating module and sending the first-level identifier to the service identifier generating module, and the service identifier generating module is used for receiving the first-level identifier sent by the identifier distributing module and generating the service identifier according to a preset service identifier generating rule and the first-level identifier. The embodiment of the application provides a service identifier generation method, which comprises the steps that when a primary identifier is required to be acquired, an identifier distribution module generates and sends a primary identifier generation request to a primary identifier generation module, the primary identifier generation module receives the primary identifier generation request sent by the identifier distribution module and selects a corresponding primary identifier generation mode according to the primary identifier generation request to generate and return a primary identifier corresponding to the primary identifier generation request, the primary identifier generation mode comprises a database generation mode for generating the primary identifier by using a database and/or a distributed node generation mode for generating the primary identifier by using a distributed node, the identifier distribution module receives the primary identifier corresponding to the primary identifier generation requ