k8s Source Analysis-----Mux and broadcaster

Source: Internet
Author: User
Tags k8s

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. )


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.