Support notifying components for config reload, listen for SIGHUP

This commit is contained in:
Neil Alexander 2018-12-29 18:51:51 +00:00
parent b4a7dab34d
commit 219fb96553
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
10 changed files with 189 additions and 36 deletions

View file

@ -65,11 +65,12 @@ type dhtReqKey struct {
// The main DHT struct.
type dht struct {
core *Core
nodeID crypto.NodeID
peers chan *dhtInfo // other goroutines put incoming dht updates here
reqs map[dhtReqKey]time.Time // Keeps track of recent outstanding requests
callbacks map[dhtReqKey]dht_callbackInfo // Search and admin lookup callbacks
core *Core
reconfigure chan bool
nodeID crypto.NodeID
peers chan *dhtInfo // other goroutines put incoming dht updates here
reqs map[dhtReqKey]time.Time // Keeps track of recent outstanding requests
callbacks map[dhtReqKey]dht_callbackInfo // Search and admin lookup callbacks
// These next two could be replaced by a single linked list or similar...
table map[crypto.NodeID]*dhtInfo
imp []*dhtInfo
@ -78,6 +79,18 @@ type dht struct {
// Initializes the DHT.
func (t *dht) init(c *Core) {
t.core = c
t.reconfigure = make(chan bool, 1)
go func() {
for {
select {
case _ = <-t.reconfigure:
t.core.configMutex.RLock()
t.core.log.Println("Notified: dht")
t.core.configMutex.RUnlock()
continue
}
}
}()
t.nodeID = *t.core.GetNodeID()
t.peers = make(chan *dhtInfo, 1024)
t.callbacks = make(map[dhtReqKey]dht_callbackInfo)