Tweaks to pinecone demo to shutdown more cleanly

This commit is contained in:
Devon Hudson 2023-02-24 15:41:47 -07:00
parent 3d31b131fc
commit b28406c7d0
No known key found for this signature in database
GPG key ID: CD06B18E77F6A628
3 changed files with 62 additions and 28 deletions

View file

@ -38,7 +38,7 @@ type RelayServerRetriever struct {
relayServersQueried map[gomatrixserverlib.ServerName]bool
queriedServersMutex sync.Mutex
running atomic.Bool
quit <-chan bool
quit chan bool
}
func NewRelayServerRetriever(
@ -46,7 +46,7 @@ func NewRelayServerRetriever(
serverName gomatrixserverlib.ServerName,
federationAPI federationAPI.FederationInternalAPI,
relayAPI relayServerAPI.RelayInternalAPI,
quit <-chan bool,
quit chan bool,
) RelayServerRetriever {
return RelayServerRetriever{
ctx: ctx,
@ -151,6 +151,7 @@ func (r *RelayServerRetriever) SyncRelayServers(stop <-chan bool) {
if !t.Stop() {
<-t.C
}
logrus.Info("Stopped relay server retriever")
return
case <-t.C:
}

View file

@ -60,7 +60,7 @@ func TestRelayRetrieverInitialization(t *testing.T) {
"server",
&FakeFedAPI{},
&FakeRelayAPI{},
make(<-chan bool),
make(chan bool),
)
retriever.InitializeRelayServers(logrus.WithField("test", "relay"))
@ -74,7 +74,7 @@ func TestRelayRetrieverSync(t *testing.T) {
"server",
&FakeFedAPI{},
&FakeRelayAPI{},
make(<-chan bool),
make(chan bool),
)
retriever.InitializeRelayServers(logrus.WithField("test", "relay"))