From 0592c3954632f919952347601331c3770e6c762f Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Fri, 10 Jul 2015 11:37:57 -0600 Subject: [PATCH] loadbalancer: do not expose sync.Mutex as public field --- loadbalancer/static_publisher.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/loadbalancer/static_publisher.go b/loadbalancer/static_publisher.go index 55d5d31fd..42ae831b0 100644 --- a/loadbalancer/static_publisher.go +++ b/loadbalancer/static_publisher.go @@ -17,23 +17,23 @@ func NewStaticPublisher(endpoints []endpoint.Endpoint) *StaticPublisher { // StaticPublisher holds a static set of endpoints. type StaticPublisher struct { - sync.Mutex + mu sync.Mutex current []endpoint.Endpoint subscribers map[chan<- []endpoint.Endpoint]struct{} } // Subscribe implements Publisher. func (p *StaticPublisher) Subscribe(c chan<- []endpoint.Endpoint) { - p.Lock() - defer p.Unlock() + p.mu.Lock() + defer p.mu.Unlock() p.subscribers[c] = struct{}{} c <- p.current } // Unsubscribe implements Publisher. func (p *StaticPublisher) Unsubscribe(c chan<- []endpoint.Endpoint) { - p.Lock() - defer p.Unlock() + p.mu.Lock() + defer p.mu.Unlock() delete(p.subscribers, c) } @@ -42,8 +42,8 @@ func (p *StaticPublisher) Stop() {} // Replace replaces the endpoints and notifies all subscribers. func (p *StaticPublisher) Replace(endpoints []endpoint.Endpoint) { - p.Lock() - defer p.Unlock() + p.mu.Lock() + defer p.mu.Unlock() p.current = endpoints for c := range p.subscribers { c <- p.current