various: standardize registry APIs; truncate metrics responses at 10MB

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I428255e61f8d2211fec0c320527b8e066a6a6964
This commit is contained in:
raf 2026-03-10 10:39:52 +03:00
commit c925cca321
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
3 changed files with 73 additions and 0 deletions

View file

@ -54,3 +54,20 @@ func (r *CustomEventRegistry) OverflowCount() int {
defer r.mu.RUnlock()
return r.overflowCount
}
// Contains checks if an event name exists in the registry.
func (r *CustomEventRegistry) Contains(eventName string) bool {
r.mu.RLock()
defer r.mu.RUnlock()
_, exists := r.events[eventName]
return exists
}
// Count returns the number of unique events in the registry.
func (r *CustomEventRegistry) Count() int {
r.mu.RLock()
defer r.mu.RUnlock()
return len(r.events)
}

View file

@ -56,3 +56,20 @@ func (r *ReferrerRegistry) OverflowCount() int {
defer r.mu.RUnlock()
return r.overflowCount
}
// Contains checks if a source exists in the registry.
func (r *ReferrerRegistry) Contains(source string) bool {
r.mu.RLock()
defer r.mu.RUnlock()
_, exists := r.sources[source]
return exists
}
// Count returns the number of unique sources in the registry.
func (r *ReferrerRegistry) Count() int {
r.mu.RLock()
defer r.mu.RUnlock()
return len(r.sources)
}