initial commit

This commit is contained in:
2025-10-17 09:29:37 +03:00
commit 9739ede62e
25 changed files with 2270 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
package collector
import (
"sync"
)
type Registry struct {
collectors []Collector
mutex sync.RWMutex
}
func NewRegistry() *Registry {
return &Registry{
collectors: make([]Collector, 0),
}
}
func (r *Registry) Register(collector Collector) {
r.mutex.Lock()
defer r.mutex.Unlock()
r.collectors = append(r.collectors, collector)
}
func (r *Registry) GetCollectors() []Collector {
r.mutex.RLock()
defer r.mutex.RUnlock()
result := make([]Collector, len(r.collectors))
copy(result, r.collectors)
return result
}