allow access to the field for convenience
decalarative configuration is superior. the thread-safety because important during normal operation
Brian Tiger Chow committed
Feb 4, 2015 at 18:50 UTC
db644fe1b7d612082395d07feb5a7f1b544a0260
1 file changed
+5
-4
core/corehttp/gateway.go
+5
-4
@@ -48,12 +48,12 @@ type Decider func(string) bool
48
49
type BlockList struct {
50
mu sync.RWMutex
51
- d Decider
51
+ Decider Decider
52
}
53
54
func (b *BlockList) ShouldAllow(s string) bool {
55
b.mu.RLock()
56
- d := b.d
56
+ d := b.Decider
57
b.mu.RUnlock()
58
if d == nil {
59
return true
@@ -61,10 +61,11 @@ func (b *BlockList) ShouldAllow(s string) bool {
61
return d(s)
62
}
63
64
-// SetDecider atomically swaps the blocklist's decider
64
+// SetDecider atomically swaps the blocklist's decider. This method is
65
+// thread-safe.
66
func (b *BlockList) SetDecider(d Decider) {
67
b.mu.Lock()
67
- b.d = d
68
+ b.Decider = d
69
b.mu.Unlock()
70
}
71