mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Support notifying components for config reload, listen for SIGHUP
This commit is contained in:
parent
b4a7dab34d
commit
219fb96553
10 changed files with 189 additions and 36 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue