-----Star topological fractal design of Golang distributed design pattern
In the previous layered design, the simple pipelining principle was used to realize the simple State transfer design. As follows
We will consider another situation in this article. For example, process management in the Linux kernel. All processes have a parent process. When a child process is running normally, there is basically no communication with the parent process. However, when a child process dies, the parent process is notified of its parent process for resource reclamation. When the parent process dies, the child process dies with the parent process, or the child process is managed by the parent process of the parent process. Similar to the following figure
Each of these processes has its own parent process, and it is possible to have its own child processes.
In this kind of management, the parent-child relationship, or the relationship between the manager and the manager. Being a manager, you can run it on your own, but to inform the manager or manager of some of its status, you can periodically get the status of the manager.
Here is an example of a Peer-to-peer downloader:
I. Division of functions, formation of managers and being managers
1) Download Task Manager. (for adding, deleting tasks, and controlling the speed of task downloads, for some policy management)
2) Download the task module. (For specific individual task downloads, you can control peer)
3) equivalent peer module. (Peer-to-peer interactive peer communication, data interaction)
There are two star topological models here.
1 Download Task Manager, for Manager, control task Add, delete, etc. Download task module, for the manager, for a specific task of the download.
Download Manager, can real-time control download module, download module, download speed, download completion status to the Download management report.
2 Download task module, for managers, control Peer-to-peer peer acquisition, creation, etc. Peer-to-peer peer modules, for managers, for specific communications, data interactions, etc.
Its two star structures, which form a fractal structure of the star type
Second, the definition of interface
1 The manager, defines a manager's interface, which is used to pass to the manager.
2 by the manager, define a state interface, for managers to acquire, control the status of the manager.
Third, the operation
1, the manager initializes, and runs
2, add to be the manager.
When adding, the admin interface is passed to the manager.
The star topology fractal design can be classified into a kind of system based on functional management. Each function is independent, and through the interface, carries on the weak communication, realizes the escalation, the management and so on behavior. But each function can be loosely coupled.
Hao Haohua First Draft
The Long Crescent Moon Road
QQ 29185807
August 22, 2014