bridgev2: add optional stop method for network connectors
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run

This commit is contained in:
Tulir Asokan 2024-10-14 19:47:22 +03:00
commit 965008e846
2 changed files with 8 additions and 0 deletions

View file

@ -216,6 +216,9 @@ func (br *Bridge) Stop() {
}
wg.Wait()
br.cacheLock.Unlock()
if stopNet, ok := br.Network.(StoppableNetwork); ok {
stopNet.Stop()
}
err := br.DB.Close()
if err != nil {
br.Log.Warn().Err(err).Msg("Failed to close database")

View file

@ -229,6 +229,11 @@ type NetworkConnector interface {
CreateLogin(ctx context.Context, user *User, flowID string) (LoginProcess, error)
}
type StoppableNetwork interface {
// Stop is called when the bridge is stopping, after all network clients have been disconnected.
Stop()
}
// DirectMediableNetwork is an optional interface that network connectors can implement to support direct media access.
//
// If the Matrix connector has direct media enabled, SetUseDirectMedia will be called