TUN-1350: Enhance error messages with cloudflarestatus.com link, if relevant

This commit is contained in:
Nick Vollmar
2019-01-10 14:55:44 -06:00
parent 8de19dc647
commit 62b1ab8c98
25 changed files with 1632 additions and 33 deletions

View File

@@ -0,0 +1,37 @@
// Copyright (c) 2013 CloudFlare, Inc.
// This code is based on golang example from "container/heap" package.
package lrucache
type priorityQueue []*entry
func (pq priorityQueue) Len() int {
return len(pq)
}
func (pq priorityQueue) Less(i, j int) bool {
return pq[i].expire.Before(pq[j].expire)
}
func (pq priorityQueue) Swap(i, j int) {
pq[i], pq[j] = pq[j], pq[i]
pq[i].index = i
pq[j].index = j
}
func (pq *priorityQueue) Push(e interface{}) {
n := len(*pq)
item := e.(*entry)
item.index = n
*pq = append(*pq, item)
}
func (pq *priorityQueue) Pop() interface{} {
old := *pq
n := len(old)
item := old[n-1]
item.index = -1
*pq = old[0 : n-1]
return item
}