Event publishing and subscribing service system and method and computer readable storage medium

By introducing an event publishing and subscription service system into the operating system of an electronic device, and using the event management module and channel management module, the complexity of event transmission and resource waste problems between different software are solved, and event delivery with low latency and resource saving is achieved.

CN119603657APending Publication Date: 2025-03-11QNAP SYST INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311344290.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2023-09-08
Filing Date
2023-10-17
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

In the prior art, event transmission between different software in the operating system of an electronic device has complexity and resource waste, resulting in system errors and excessive resource utilization.

Method used

It provides an event publishing and subscription service system, including an event management module and a channel management module, and realizes integrated notification of events and low-latency delivery through the management of registration information and subscription information.

Benefits of technology

It realizes the integration of event delivery and low-latency delivery, saves system resources, reduces system errors, and simplifies the development process of event publishers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119603657A_ABST
    Figure CN119603657A_ABST
Patent Text Reader

Abstract

The invention discloses an event publishing and subscribing service system and method and a computer readable storage medium, and the method comprises the steps: receiving registration information provided by an event publisher, and recording the registration information in an event publisher list; when an event published by the event publisher is received, at least one channel to which the event belongs is inquired in the registration information, and whether subscription information of event subscribers is recorded in an event subscriber list of each channel to which the event belongs is inquired; and for each piece of subscription information, sending the event to the event subscriber to which the subscription information belongs through a protocol specified by the subscription information, or executing at least one instruction specified by the subscription information according to the event, wherein the event publisher and the event subscribers are installed in the same operating system of the same electronic device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to an event publishing and subscription service technology, and more particularly to an integrated notification mechanism for events occurring in different software in an operating system of an electronic device. Background Art

[0002] As the functions of electronic devices become more complex and diverse, their operating systems will design many different modules or services based on different functions through different programming languages ​​or software tools to specifically handle certain specific functions. Since it is a complex operating system, there must be events and notifications between different modules or services so that the modules or services can take corresponding supporting measures.

[0003] For example, an electronic device may include a photo management system. Whenever a user adds a photo, the photo management system will create a thumbnail of the photo, then create an index in the file management system, and notify the user's application. In addition, the electronic device may also include a video management system. Whenever a user adds a video, the video management system will grab the first picture of the video to create the cover of the video, then create an index in the file management system, and notify the user's application.

[0004] In order to achieve the above functions, the prior art generally adopts the following Figure 1 The design shown in the figure, wherein the electronic device includes a photo management system 11, a video management system 12, a file management system 13, and a user application 14. Accordingly, the photo management system 11 is additionally designed with interfaces 111 and 112, so as to send the event of adding a new photo to the file management system 13 and the application 14 through the interfaces 111 and 112, respectively. In addition, the video management system 12 is additionally designed with interfaces 121 and 122, so as to send the event of adding a new video to the file management system 13 and the application 14 through the interfaces 121 and 122, respectively. For example, the interfaces 111 and 121 may be interfaces of a command line interface hook (CLI Hook), and the interfaces 112 and 122 may be interfaces of an inter-process communication (IPC) interface or a WebSocket interface.

[0005] However, these event transmission functions are actually duplicated. If these duplicate event transmission functions are encapsulated into a function library, there will be many design complexities due to the different programming languages ​​used to develop event publishers. For example, the photo management system is developed in C language, while the audio and video management system is developed in Python language. Since function libraries of different programming languages ​​are not universal, this will lead to a waste of manpower and resources during development, and easily cause system errors.

[0006] like Figure 1 As shown, both the photo management system 11 and the video and audio management system 12 implement an IPC or WebSocket interface as an event transmission method for adding new photos or videos. However, since the working nature and content of the IPC or WebSocket interfaces 112 and 122 are mostly similar, it is necessary to run their program codes in both the photo management system 11 and the video and audio management system 12. This will result in the need to occupy more storage space in the operating system, such as a hard disk drive (HDD), a solid-state drive (SSD) or a flash memory to repeatedly record too much program code. During operation, it is also necessary to use twice as much system memory and processor computing resources to complete the operation of the above program code. The above memory can be a double data rate (DDR) memory, such as a DDR4 or DDR5 memory. Therefore, this will cause a problem of waste of system resources.

[0007] An ideal event notification mechanism must integrate event delivery between different applications or services, should not be too complicated, must be able to save system resources, must provide low-latency real-time event delivery, and must be able to notify software such as services that have not yet been started. In the prior art, although there are many ways to deliver events, no one way can meet all of the above requirements. Therefore, there are various event delivery methods between modules or services in the current operating system, and the modules or services that publish events often need to add a variety of event transmission methods to meet various different requirements. In addition, when developing a module waiting for an event, it may also be necessary to spend additional design and resources to add the function of receiving events in order to meet the limitations of the event sending module itself, resulting in itself being too complicated and losing flexibility. At the same time, these problems will also cause too many repeated functions in the system, resulting in the problem of waste of system resources. Summary of the invention

[0008] To solve the above problems, the present invention provides an event publishing and subscription service system, including: an event management module, used to receive registration information provided by an event publisher, so as to record the registration information in an event publisher list, and when receiving an event published by the event publisher, query at least one channel to which the event belongs in the registration information; and a channel management module, used to receive the event and the at least one channel to which the event belongs from the event management module, so as to query whether the subscription information of the event subscriber has been recorded in the event subscriber list of each channel to which the event belongs, and for each subscription information, send the event to the event subscriber to which the subscription information belongs through the protocol specified by the subscription information, or execute at least one instruction specified by the subscription information according to the event, wherein the event management module, the channel management module, the event publisher and each of the event subscribers are installed in the same operating system of the same electronic device.

[0009] The present invention further provides an event publishing and subscription service method, which is executed in an operating system of an electronic device, including: receiving registration information provided by an event publisher; recording the registration information in an event publisher list; when receiving an event published by the event publisher, querying at least one channel to which the event belongs in the registration information; querying whether the subscription information of the event subscriber has been recorded in the event subscriber list of each channel to which the event belongs; and for each subscription information, sending the event to the event subscriber to which the subscription information belongs through the protocol specified by the subscription information, or executing at least one instruction specified by the subscription information according to the event, wherein the event publisher and each of the event subscribers are installed in the operating system.

[0010] In one embodiment, the event management module, the channel management module, the event publisher and / or each of the event subscribers are installed in the same operating system of the same electronic device, or are processes executed in the same operating system of the same electronic device.

[0011] The present invention further provides a computer-readable storage medium storing instructions, wherein the instructions are read by an electronic device to execute the above-mentioned event publishing and subscription service method.

[0012] The present invention can provide a simple event publishing and subscription service, which can not only integrate event transmission between different applications or services, but also provide low-latency real-time event transmission, notify software such as services that have not yet been started, save system resources, and reduce system errors. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 Publish schematic diagrams for events of the prior art.

[0014] Figure 2Schematic diagram of an event publishing and subscription service system according to an embodiment of the present invention.

[0015] Figure 3 The figure is a flow chart of an event publishing and subscription service method according to an embodiment of the present invention.

[0016] Figure 4 FIG. 4 is a schematic diagram of event publishing according to an embodiment of the present invention.

[0017] Main component symbols

[0018] 11 Photo Management System

[0019] 111,112 Interface

[0020] 12 Audio and video management system

[0021] 121,122 Interface

[0022] 13 Document Management System

[0023] 14 Applications

[0024] 2 Event Publishing and Subscription Service System

[0025] Channel 201-202

[0026] 21 Event Management Module

[0027] 211 Event Publisher List

[0028] 212 Publisher Operation Interface

[0029] 22 Channel Management Module

[0030] Channels 221-224

[0031] 231~234 Event Subscriber List

[0032] 241~243 Event publisher

[0033] 251~255 Event subscribers

[0034] Steps 31-38

[0035] 41 Photo Management System

[0036] 42 Audio and video management system

[0037] 43 Document Management System

[0038] 44 applications. DETAILED DESCRIPTION

[0039] The following describes the implementation of the present invention through specific embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification.

[0040] Figure 2 Schematic diagram of an event publishing and subscription service system 2 according to an embodiment of the present invention. The event publishing and subscription service system 2 includes an event management module 21 and a channel management module 22. The event management module 21 and the channel management module 22 are connected to each other for communication.

[0041] The event management module 21 provides a publisher operation interface 212 to receive registration information provided by event publishers 241-243 and events published by event publishers 241-243. The publisher operation interface 212 may be an application programming interface (API) for use by event publishers 241-243. In addition, the event management module 21 records the registration information provided by event publishers 241-243 in the event publisher list 211.

[0042] The channel management module 22 is used to manage channels 221 to 224. Channels 221 to 224 respectively include an event subscriber list 231 to 234 for recording subscription information provided by event subscribers 251 to 255. In addition, the channel of this embodiment is a data structure for accommodating events and subscription information.

[0043] In this embodiment, the event management module 21, the channel management module 22, the event publishers 241-243 and the event subscribers 251-255 are all software or equivalents such as modules, services, tool programs or applications installed in the same operating system of the same electronic device, and are all executed by the processor of the electronic device. The electronic device can be an electronic device such as a smart watch, a smart phone, a network attached storage (NAS), a computer or a server that includes an operating system and has program execution capabilities. The event publisher list 211 and the event subscriber list 231-234 can be stored in the memory and / or hard disk of the electronic device, and can be stored in a database for easy management and query.

[0044] Figure 3 for Figure 2 The flowchart of the event publishing and subscription service method executed by the event publishing and subscription service system 2 is shown.

[0045] First, in step 31 , the event management module 21 receives registration information provided by an event publisher. Then, in step 32 , the event management module 21 records the registration information in the event publisher list 211 .

[0046] For example, the event publisher 241 can provide its registration information to the event management system 21 through the publisher operation interface 212. The registration information includes the channels to which the various types of events to be published by the event publisher 241 belong. For example, the event publisher 241 is a hardware management module in the operating system of the electronic device that is responsible for managing hardware devices. Whenever the electronic device has a new hardware device, the hardware management module can publish a new event for the hardware device. The event publisher 241 can publish new events for various hardware devices using the same channel. For example, the event of adding a new internal hard disk and the event of adding a new mouse can be attributed to the same channel 221. Each event can contain different information content depending on its type. For example, the above-mentioned event of adding a new internal hard disk can contain information content such as the slot location and model of the new hard disk. Alternatively, the event publisher 241 may classify the newly added events into multiple categories and assign them to different channels, for example, the event of a newly added hard disk is classified as a first event and assigned to a newly added channel 221, the event of a newly added network interface card is classified as a second event and assigned to another newly added channel 222, and the event of a newly added display is classified as a third event and assigned to another newly added channel 223. For another example, the event publisher 242 is a tool program for monitoring the processor temperature of the electronic device. The event publisher 242 will periodically publish notification events of the processor temperature and assign the notification events to another channel, such as channel 224.

[0047] In addition, the event publisher 241 can attribute an event not only to a single channel but also to multiple channels.

[0048] The registration information provided by the event publisher 241 also includes the publishing type of each channel to which the various types of events to be published belong, which can be a sending type or an instruction type. If the channel to which an event belongs is of the sending type, the registration information also includes the protocol specified by the event publisher 241 for sending the events of the channel to the event subscribers. The protocol is a protocol used by processes running on the same operating system to transmit information and data to each other, such as the WebSocket protocol or the Redis protocol, and the protocol specified by the event publisher 241 can include one, multiple or all protocols supported by the event publishing and subscription service system 2. Therefore, the event publisher 241 can decide how to publish the event based on the attributes of the event. For example, the event publisher 241 can specify that the event is only published to the event subscribers of the channel 221 through the IPC protocol.

[0049] In addition, a channel may be a single type of the above-mentioned sending type and command type, or may be a combination of the sending type and the command type.

[0050] In addition, the event management module 21 will also transmit the registration information to the channel management module 22, and the channel management module 22 will establish each channel to which the event to be published by the event publisher 241 belongs according to the registration information.

[0051] The remaining event publishers 242 or 243 can also provide their registration information through the publisher operation interface 212, and the event management module 21 and the channel management module 22 will receive and process their registration information in the same way.

[0052] In step 33, the channel management module 22 receives the subscription information provided by the event subscribers 251-255. Then, in step 34, the channel management module 22 records each subscription information in the event subscriber list of the channel to which each subscription information belongs.

[0053] For example, event subscriber 251 can subscribe to channels 221 and 222 from channel management module 22, so event subscriber 251 needs to provide a subscription information for each of channels 221 and 222. If channels 221 and 222 are of the sending type and the command type respectively, the subscription information provided by event subscriber 251 for channel 221 includes the protocol specified by event subscriber 251 for sending events of channel 221 to event subscriber 251, and the protocol may include one, multiple or all protocols supported by event publishing and subscription service system 2, and channel management module 22 will record the subscription information in event subscriber list 231 of channel 221.

[0054] If the registration information in the event publisher list 211 specifies all protocols, when the event publishing and subscription service system 2 increases the protocols it supports, the newly added protocols will be automatically added to the registration information without the event publisher having to re-provide the registration information.

[0055] On the other hand, event subscribers can choose to re-subscribe to the channel using the newly added protocol, or continue to subscribe to the channel using the old protocol. For example, channel 221 only supports the Redis protocol, so event subscriber 251 needs to add an additional Redis interface to subscribe to channel 221. When channel 221 adds the IPC protocol, event subscriber 251 already has the IPC function, so event subscriber 251 can remove the subscription information of the redis protocol and use IPC to subscribe to channel 221 instead. Alternatively, event subscriber 251 can also maintain the original subscription information of the specified redis protocol.

[0056] In addition, as described above, channel 222 is of instruction type, therefore, the subscription information provided by event subscriber 251 for channel 222 includes at least one instruction specified by event subscriber 251 to be executed according to the event of channel 222, and the channel management module 22 will record the subscription information in the event subscriber list 232 of channel 222.

[0057] If the event subscriber 251 wants to subscribe to a channel, and the channel has both a sending type and an instruction type, the subscription information provided by the event subscriber 251 for the channel includes the protocol specified by the event subscriber 251 for sending the events of the channel to the event subscriber 251, and the subscription information also includes at least one instruction specified by the event subscriber 251 to be executed based on the events of the channel. The channel management module 22 will record the subscription information in the event subscriber list of the channel.

[0058] The event subscriber 251 can arbitrarily select the channel to subscribe to. In detail, the event subscriber 251 can subscribe to any channel or any multiple channels from the channel management module 22.

[0059] For another example, the event subscriber 255 is a tool program for adjusting the fan speed of the processor of the electronic device, or a program or container program running in a container. The event subscriber 255 can subscribe to the send type channel 224 to periodically receive notification events of the processor temperature, and then adjust the fan speed of the processor according to the processor temperature in the notification event to prevent the processor from overheating.

[0060] The remaining event subscribers 252 ˜ 254 may also provide subscription information to the channel management module 22 to subscribe to the channel. The channel management module 22 will receive and record the subscription information provided by the event subscribers 252 ˜ 254 in the same manner.

[0061] In step 35, the event management module 21 receives the event published by the event publisher. Specifically, any event publisher 241-243 that has previously provided registration information can publish an event through the publisher operation interface 212, so that the event management module 21 receives the event.

[0062] In step 36 , the event management module 21 searches the registration information of the event publisher recorded in the event publisher list 211 for at least one channel to which the event belongs, and transmits the event and the at least one channel to which the event belongs to the channel management module 22 .

[0063] In step 37 , the channel management module 22 receives the event and the at least one channel to which the event belongs from the event management module 21 , and queries whether the subscription information of any event subscriber has been recorded in the event subscriber list of each of the channels to which the event belongs.

[0064] For each channel to which the event belongs, if no subscription information is recorded in the event subscriber list of the channel, the channel management module 22 does not perform any operation for the channel. On the contrary, if subscription information is recorded in the event subscriber list of the channel, then in step 38, the channel management module 22 uses the protocol specified by the subscription information for each subscription information recorded in the event subscriber list of the channel to send the event to the event subscriber to which the subscription information belongs, or executes the instruction specified by the subscription information according to the event.

[0065] Specifically, if a channel to which the event belongs is of the sending type, and the event subscriber list of the channel has recorded the subscription information, then for each of the subscription information, the channel management module 22 calculates the intersection of the protocol used to send the event in the registration information of the event publisher and the protocol specified by the subscription information, and then uses each protocol in the intersection to send the event to the event subscriber to which the subscription information belongs. If the protocol used to send the event in the registration information of the event publisher and the protocol specified by the subscription information do not have an intersection, the channel management module 22 does not send the event to the event subscriber.

[0066] In addition, when a plurality of subscription information is recorded in the event subscriber list of the channel, each subscription information may specify the same or different protocols.

[0067] In addition, if a channel to which the event belongs is of a command type, and subscription information has been recorded in the event subscriber list of the channel, then for each subscription information, the channel management module 22 executes at least one instruction specified by the subscription information according to the event. For example, the at least one instruction may be to write a piece of information in the operation log (log) of the operating system according to the event, or to start a service in the operating system to handle the event. For another example, the event may be a notification event that an image file has been added to a directory, and the at least one instruction may include instructions for converting the format of the image file, making a thumbnail of the image file, and notifying the photo management system in the operating system to store the image file and the thumbnail.

[0068] In addition, when a plurality of subscription information is recorded in the event subscriber list of the channel, each subscription information may specify the same or different instructions.

[0069] For example, event publisher 243 publishes an event E. According to the registration information R previously provided by event publisher 243, event E belongs to channels 221 and 222. Channel 221 is of the sending type, and its event subscriber list 231 has recorded the subscription information A1 of event subscriber 251 and the subscription information A2 of event subscriber 252. Therefore, the channel management module 22 calculates the intersection of the protocol used to send event E in the registration information R and the protocol specified by the subscription information A1, and then uses each protocol in the intersection to send event E to event subscriber 251. The channel management module 22 calculates the intersection of the protocol used to send event E in the registration information R and the protocol specified by the subscription information A2, and then uses each protocol in the intersection to send event E to event subscriber 252.

[0070] In addition, channel 222 is of instruction type, and its event subscriber list 232 has recorded the subscription information B3~B5 of event subscribers 253~255. Therefore, the channel management module 22 executes the instructions specified by subscription information B3, the instructions specified by subscription information B4 and the instructions specified by subscription information B5 according to event E respectively.

[0071] It should be noted that Figure 2 The event publishers 241 - 243 , event subscribers 251 - 255 , and channels 221 - 224 shown are merely examples, and the present invention does not limit the number of event publishers, event subscribers, and channels.

[0072] Figure 4 FIG. 4 is a schematic diagram of event publishing according to an embodiment of the present invention. Figure 4 The event publishing and subscription service system 2 of the present invention replaces Figure 1 Interfaces 111, 112, 121 and 122 in.

[0073] In this embodiment, the photo management system 41 and the audio and video management system 42 are event publishers, and the file management system 43 and the application 44 are event subscribers. The newly added photo event published by the photo management system 41 belongs to the channel 201, so the file management system 43 and the application 44 subscribe to the channel 201 to receive the newly added photo event published by the photo management system 41. In addition, the newly added video event published by the audio and video management system 42 belongs to the channel 202, so the file management system 43 and the application 44 subscribe to the channel 202 to receive the newly added video event published by the video management system 42.

[0074] Therefore, the event publisher only needs to publish the event to the event publishing and subscription service system 2, and the event can be delivered to the event subscriber waiting for the event. For the event publisher, the repeated implementation of various interfaces can be omitted to save system resources. In other words, the event publisher does not need to know what method to use to publish the event.

[0075] In addition, the event publisher only needs to publish an event once, and does not need to know how many event subscribers need services. For event subscribers, they only need to establish a connection with the event publishing and subscription service system 2 to receive events from different event publishers at the same time.

[0076] In one embodiment, the present invention further provides a computer-readable storage medium, such as a memory, a floppy disk, a hard disk, or an optical disk. The computer-readable storage medium stores instructions, and the instructions can be read by the above-mentioned electronic device to execute the above-mentioned event publishing and subscription service method.

[0077] In summary, the present invention can solve the complexity and waste of system resources (such as the execution time of the processor of the electronic device and the storage space of the memory of the electronic device) caused by many modules, services, tools or applications or equivalent software in the system sending events or waiting for events at the same time. By utilizing the event push and subscription methods and the concept of channels, events and various transmission methods are integrated to provide an event publishing and subscription service system and method, thereby, event publishers do not need to define the method of publishing events, and subscribers who need to wait for events can choose the transmission method that best suits them to receive events.

[0078] Through the present invention, all event publishers, no matter which programming language is used for development, do not need to know how event subscribers will receive events, nor do they need to implement various protocol functions or other corresponding functions by themselves. They only need to use the event publishing and subscription service system of the present invention to publish events using various protocols or trigger instructions for responding to events. Therefore, the development of event publishers can focus more on their own functions and save system resources relatively more.

[0079] In addition, through the present invention, event subscribers can specify channels to subscribe to events in the event publishing and subscription service system based on their own applications and supported methods. At the same time, event subscribers can receive events from different software in a unified format, thereby saving development costs.

[0080] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Any person skilled in the art may modify and alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be as set forth in the claims.

Claims

1. An event publishing and subscription service system, comprising: An event management module, for receiving registration information provided by an event publisher, recording the registration information in an event publisher list, and when receiving an event published by the event publisher, querying at least one channel to which the event belongs in the registration information; as well as a channel management module, for receiving the event and the at least one channel to which the event belongs from the event management module, to query whether the event subscriber list of each channel to which the event belongs has recorded the subscription information of the event subscriber, and for each subscription information, to send the event to the event subscriber to which the subscription information belongs through the protocol specified by the subscription information, or to execute at least one instruction specified by the subscription information according to the event, The event management module, the channel management module, the event publisher and each of the event subscribers are installed in the same operating system of the same electronic device.

2. The event publishing and subscription service system according to claim 1, wherein: The registration information includes the channels to which the various types of events to be published by the event publisher belong.

3. The event publishing and subscription service system as claimed in claim 2, wherein: For each channel to which each event of the type to be published by the event publisher belongs, if the channel is of the sending type, the registration information also includes the protocol specified by the event publisher for sending events of the type.

4. The event publishing and subscription service system as claimed in claim 3, wherein: For each subscription information in each channel to which the event published by the event publisher belongs and which is of the sending type, the channel management module is also used to calculate the intersection of the protocol used to send the event in the registration information and the protocol specified by the subscription information, and then send the event to the event subscriber to which the subscription information belongs through each protocol in the intersection.

5. The event publishing and subscription service system according to claim 1, wherein: The channel management module is also used to receive each subscription information provided by each event subscriber, and record each subscription information in the event subscriber list of the channel to which the subscription information belongs.

6. An event publishing and subscription service method, executed in an operating system of an electronic device, comprising: Receive registration information provided by an event publisher; Record the registration information in the event publisher list; When receiving the event published by the event publisher, querying at least one channel to which the event belongs in the registration information; Check whether the subscription information of the event subscriber has been recorded in the event subscriber list of each channel to which the event belongs; as well as For each subscription information, the event is sent to the event subscriber to which the subscription information belongs through the protocol specified by the subscription information, or at least one instruction specified by the subscription information is executed according to the event. The event publisher and each of the event subscribers are installed in the operating system.

7. The event publishing and subscription service method according to claim 6, wherein: The registration information includes the channels to which the various types of events to be published by the event publisher belong.

8. The event publishing and subscription service method according to claim 6, wherein: For each channel to which each event of the type to be published by the event publisher belongs, if the channel is of the sending type, the registration information also includes the protocol specified by the event publisher for sending events of the type.

9. The event publishing and subscription service method according to claim 6, further comprising: Receive the subscription information provided by each event subscriber; as well as Each subscription information is recorded in the event subscriber list of the channel to which the subscription information belongs.

10. A computer-readable storage medium storing instructions, wherein the instructions are read by an electronic device to execute the event publishing and subscription service method according to any one of claims 6 to 9.