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 FilteredStreams map[string][]byte
FilteredChannels 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 Grp *stop.Group
ShutdownChan chan struct{}
DoneChan chan struct{}
Cleanup func() Cleanup func()
} }
@ -601,8 +599,7 @@ func GetDBColumnFamilies(name string, secondayPath string, cfNames []string) (*R
LastState: nil, LastState: nil,
Height: 0, Height: 0,
Headers: nil, Headers: nil,
ShutdownChan: make(chan struct{}, 1), Grp: nil,
DoneChan: make(chan struct{}, 1),
} }
err = myDB.ReadDBState() //TODO: Figure out right place for this 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) log.Infof("Error detecting changes: %#v", err)
} }
select { select {
case <-db.ShutdownChan: case <-db.Grp.Ch():
db.DoneChan <- struct{}{} db.Grp.Done()
return return
case <-time.After(time.Millisecond * 10): case <-time.After(time.Millisecond * 10):
} }

View file

@ -93,8 +93,7 @@ func OpenAndFillTmpDBColumnFamlies(filePath string) (*dbpkg.ReadOnlyDBColumnFami
LastState: nil, LastState: nil,
Height: 0, Height: 0,
Headers: nil, Headers: nil,
ShutdownChan: make(chan struct{}, 1), Grp: nil,
DoneChan: make(chan struct{}, 1),
} }
// err = dbpkg.ReadDBState(myDB) //TODO: Figure out right place for this // 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) logrus.Warning(err)
} }
myDB.Grp = stop.New(grp) myDB.Grp = stop.New(grp)
myDB.Grp.Add(1)
} }
// Determine which chain to use based on db and cli values // Determine which chain to use based on db and cli values