Add mode that prints multiple worker status in console
This commit is contained in:
32
hostPool/hostPool.go
Normal file
32
hostPool/hostPool.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package gemini
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ipPool = IpAddressPool{IPs: make(map[string]int)} //nolint:gochecknoglobals
|
||||||
|
var hostPool = HostPool{hostnames: make(map[string]struct{})} //nolint:gochecknoglobals
|
||||||
|
|
||||||
|
type HostPool struct {
|
||||||
|
hostnames map[string]struct{}
|
||||||
|
Lock sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *HostPool) Add(key string) {
|
||||||
|
p.Lock.Lock()
|
||||||
|
defer p.Lock.Unlock()
|
||||||
|
p.hostnames[key] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *HostPool) Get(key string) bool {
|
||||||
|
p.Lock.RLock()
|
||||||
|
defer p.Lock.RUnlock()
|
||||||
|
_, ok := p.hostnames[key]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *HostPool) Delete(key string) {
|
||||||
|
p.Lock.Lock()
|
||||||
|
defer p.Lock.Unlock()
|
||||||
|
delete(p.hostnames, key)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user