Rename watch.Mux -> watch.Broadcaster

A few reasons:
- Mux is already widely used in the codebase to refer to a http handler mux.
- Original meaning of Mux was something which sent a chose one of several inputs to
  and output.  This sends one output to all outputs.  Broadcast captures that idea
  better.
- Aligns with similar class config.Broadcaster (see #2747)
This commit is contained in:
Eric Tune
2014-12-04 00:30:51 -08:00
parent ffcbe2fa10
commit 3f285269cc
6 changed files with 47 additions and 47 deletions

View File

@@ -33,13 +33,13 @@ type GenericRegistry struct {
ObjectList runtime.Object
sync.Mutex
Mux *watch.Mux
Broadcaster *watch.Broadcaster
}
func NewGeneric(list runtime.Object) *GenericRegistry {
return &GenericRegistry{
ObjectList: list,
Mux: watch.NewMux(0),
ObjectList: list,
Broadcaster: watch.NewBroadcaster(0),
}
}
@@ -54,7 +54,7 @@ func (r *GenericRegistry) List(ctx api.Context, m generic.Matcher) (runtime.Obje
func (r *GenericRegistry) Watch(ctx api.Context, m generic.Matcher, resourceVersion string) (watch.Interface, error) {
// TODO: wire filter down into the mux; it needs access to current and previous state :(
return r.Mux.Watch(), nil
return r.Broadcaster.Watch(), nil
}
func (r *GenericRegistry) Get(ctx api.Context, id string) (runtime.Object, error) {
@@ -67,7 +67,7 @@ func (r *GenericRegistry) Create(ctx api.Context, id string, obj runtime.Object)
r.Lock()
defer r.Unlock()
r.Object = obj
r.Mux.Action(watch.Added, obj)
r.Broadcaster.Action(watch.Added, obj)
return r.Err
}
@@ -75,13 +75,13 @@ func (r *GenericRegistry) Update(ctx api.Context, id string, obj runtime.Object)
r.Lock()
defer r.Unlock()
r.Object = obj
r.Mux.Action(watch.Modified, obj)
r.Broadcaster.Action(watch.Modified, obj)
return r.Err
}
func (r *GenericRegistry) Delete(ctx api.Context, id string) error {
r.Lock()
defer r.Unlock()
r.Mux.Action(watch.Deleted, r.Object)
r.Broadcaster.Action(watch.Deleted, r.Object)
return r.Err
}

View File

@@ -30,13 +30,13 @@ type PodRegistry struct {
Pods *api.PodList
sync.Mutex
mux *watch.Mux
broadcaster *watch.Broadcaster
}
func NewPodRegistry(pods *api.PodList) *PodRegistry {
return &PodRegistry{
Pods: pods,
mux: watch.NewMux(0),
Pods: pods,
broadcaster: watch.NewBroadcaster(0),
}
}
@@ -64,8 +64,8 @@ func (r *PodRegistry) ListPods(ctx api.Context, selector labels.Selector) (*api.
}
func (r *PodRegistry) WatchPods(ctx api.Context, resourceVersion string, filter func(*api.Pod) bool) (watch.Interface, error) {
// TODO: wire filter down into the mux; it needs access to current and previous state :(
return r.mux.Watch(), nil
// TODO: wire filter down into the broadcaster; it needs access to current and previous state :(
return r.broadcaster.Watch(), nil
}
func (r *PodRegistry) GetPod(ctx api.Context, podId string) (*api.Pod, error) {
@@ -78,7 +78,7 @@ func (r *PodRegistry) CreatePod(ctx api.Context, pod *api.Pod) error {
r.Lock()
defer r.Unlock()
r.Pod = pod
r.mux.Action(watch.Added, pod)
r.broadcaster.Action(watch.Added, pod)
return r.Err
}
@@ -86,13 +86,13 @@ func (r *PodRegistry) UpdatePod(ctx api.Context, pod *api.Pod) error {
r.Lock()
defer r.Unlock()
r.Pod = pod
r.mux.Action(watch.Modified, pod)
r.broadcaster.Action(watch.Modified, pod)
return r.Err
}
func (r *PodRegistry) DeletePod(ctx api.Context, podId string) error {
r.Lock()
defer r.Unlock()
r.mux.Action(watch.Deleted, r.Pod)
r.broadcaster.Action(watch.Deleted, r.Pod)
return r.Err
}