Server endpoints goroutine refactor #69

Merged
jeffreypicard merged 18 commits from server-endpoints-goroutine-refactor into master 2022-10-25 07:48:13 +02:00
3 changed files with 5 additions and 8 deletions
Showing only changes of commit 31e91f67c8 - Show all commits

View file

@ -60,8 +60,6 @@ type ReadOnlyDBColumnFamily struct {
FilteredStreams map[string][]byte
FilteredChannels map[string][]byte
moodyjon commented 2022-10-14 16:14:51 +02:00 (Migrated from github.com)
Review

OpenIterators, ItMut not needed anymore.

`OpenIterator`s, `ItMut` not needed anymore.
Grp *stop.Group
ShutdownChan chan struct{}
DoneChan chan struct{}
Cleanup func()
}
@ -601,8 +599,7 @@ func GetDBColumnFamilies(name string, secondayPath string, cfNames []string) (*R
LastState: nil,
Height: 0,
Headers: nil,
ShutdownChan: make(chan struct{}, 1),
DoneChan: make(chan struct{}, 1),
Grp: nil,
}
err = myDB.ReadDBState() //TODO: Figure out right place for this
@ -694,8 +691,8 @@ func (db *ReadOnlyDBColumnFamily) RunDetectChanges(notifCh chan<- interface{}) {
log.Infof("Error detecting changes: %#v", err)
}
select {
case <-db.ShutdownChan:
db.DoneChan <- struct{}{}
case <-db.Grp.Ch():
db.Grp.Done()
return
case <-time.After(time.Millisecond * 10):
}

View file

@ -93,8 +93,7 @@ func OpenAndFillTmpDBColumnFamlies(filePath string) (*dbpkg.ReadOnlyDBColumnFami
LastState: nil,
Height: 0,
Headers: nil,
ShutdownChan: make(chan struct{}, 1),
DoneChan: make(chan struct{}, 1),
Grp: nil,
}
// err = dbpkg.ReadDBState(myDB) //TODO: Figure out right place for this

View file

@ -275,6 +275,7 @@ func MakeHubServer(grp *stop.Group, args *Args) *Server {
logrus.Warning(err)
}
myDB.Grp = stop.New(grp)
myDB.Grp.Add(1)
}
// Determine which chain to use based on db and cli values