summaryrefslogtreecommitdiff
path: root/usagepool.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-09-03 12:10:11 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-09-03 12:10:11 -0600
commitccfb12347b1d2f65b279352116527df430e0fba6 (patch)
tree6483eadfad67c87a280b3e77ec8bd50a730f98e7 /usagepool.go
parent026df7c5cb33331d223afc6a9599274e8c89dfd9 (diff)
reverse_proxy: Implement active health checks
Diffstat (limited to 'usagepool.go')
-rw-r--r--usagepool.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/usagepool.go b/usagepool.go
index 3b8e975..dd4f606 100644
--- a/usagepool.go
+++ b/usagepool.go
@@ -80,6 +80,14 @@ func (up *UsagePool) LoadOrStore(key, val interface{}) (actual interface{}, load
return
}
+// Range iterates the pool the same way sync.Map.Range does.
+// This does not affect usage counts.
+func (up *UsagePool) Range(f func(key, value interface{}) bool) {
+ up.pool.Range(func(key, value interface{}) bool {
+ return f(key, value.(*usagePoolVal).value)
+ })
+}
+
type usagePoolVal struct {
usage int32 // accessed atomically; must be 64-bit aligned for 32-bit systems
value interface{}