This article QQ space link: http://user.qzone.qq.com/29185807/blog/1460616602
This article csdn Links: http://blog.csdn.net/screscent/article/details/51151550
In the k8s source code, there are a lot of use of MUX and broadcaster. These two things are very simple in themselves, but more and more feel, do not take these two things to explain, fear that there will be a lot of things will not be clear. So it is better to explain.
Source code in K8s.io\kubernetes\pkg\util\config Mux
Look at the structure and how to build it first.
Let's take another look at the merger.
It's simple mux two things, a Chan map and a merger interface. From the usage point of view, in fact, MUX is a combination of multiple producers.
Let's see how he uses it.
The code above is the producer's registration and returns a conduit for the producer to deliver the goods.
Mux through Chan map to save the transport pipeline, and to the new producers are running a listen
Listen is very simple, it is an intermediate process that will send the producer over the items through the merge (merge operation)
MUX is very simple, but there are a lot of applications in k8s.
broadcaster
Broadcast events, the application of this in k8s is also very much. Actually look at the source to know its very simple
Let's look at the structure and how to build it.
It's simple, it's a collection of listener.
Listener is actually a interface with OnUpdate.
Now let's look at the usage
First of course is registered listener
And then there's the event notification.
Summary
Although these two things are very simple, but the application is very much. If it is not clear to this, may be to understand the k8s source code caused a certain degree of difficulty.
Hao Haohua
QQ Crescent moon Lonely Road length 29185807
April 14, 2016
(Copyright statement: This article for the author original, if you need to reprint, please notify me, and indicate the source and author.) Reproduced without authorization, reserve the right to pursue its infringement. )