MCPcopy Create free account
hub / github.com/cortexproject/cortex / hasQueryAttributeRegexChanged

Method hasQueryAttributeRegexChanged

pkg/util/validation/limits.go:497–523  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

495}
496
497func (l *Limits) hasQueryAttributeRegexChanged() bool {
498 var newHash uint64
499 h := xxhash.New()
500
501 if l.QueryPriority.Enabled {
502 for _, priority := range l.QueryPriority.Priorities {
503 for _, attribute := range priority.QueryAttributes {
504 addToHash(h, attribute.Regex)
505 addToHash(h, attribute.UserAgentRegex)
506 }
507 }
508 }
509 if l.QueryRejection.Enabled {
510 for _, attribute := range l.QueryRejection.QueryAttributes {
511 addToHash(h, attribute.Regex)
512 addToHash(h, attribute.UserAgentRegex)
513 }
514 }
515
516 newHash = h.Sum64()
517
518 if newHash != l.queryAttributeRegexHash {
519 l.queryAttributeRegexHash = newHash
520 return true
521 }
522 return false
523}
524
525func addToHash(h *xxhash.Digest, regex string) {
526 if regex == "" {

Implementers 1

Overridespkg/util/validation/limits.go

Calls 2

addToHashFunction · 0.85
Sum64Method · 0.80

Tested by 1