mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
feat(GODT-2500): Reorganise async methods.
This commit is contained in:
@ -33,6 +33,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ProtonMail/gluon/async"
|
||||
"github.com/ProtonMail/go-proton-api"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/bridge"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/certs"
|
||||
@ -192,9 +193,7 @@ func NewService(
|
||||
}
|
||||
|
||||
func (s *Service) handlePanic() {
|
||||
if s.panicHandler != nil {
|
||||
s.panicHandler.HandlePanic()
|
||||
}
|
||||
async.HandlePanic(s.panicHandler)
|
||||
}
|
||||
|
||||
func (s *Service) initAutostart() {
|
||||
|
||||
@ -49,7 +49,7 @@ func (s *Service) RunEventStream(request *EventStreamRequest, server Bridge_RunE
|
||||
// if events occurred before streaming started, they've been queued. Now that the stream channel is available
|
||||
// we can flush the queued
|
||||
go func() {
|
||||
defer s.panicHandler.HandlePanic()
|
||||
defer s.handlePanic()
|
||||
|
||||
s.eventQueueMutex.Lock()
|
||||
defer s.eventQueueMutex.Unlock()
|
||||
|
||||
@ -70,7 +70,7 @@ func (s *Service) SetUserSplitMode(ctx context.Context, splitMode *UserSplitMode
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer s.panicHandler.HandlePanic()
|
||||
defer s.handlePanic()
|
||||
defer func() { _ = s.SendEvent(NewUserToggleSplitModeFinishedEvent(splitMode.UserID)) }()
|
||||
|
||||
var targetMode vault.AddressMode
|
||||
@ -121,7 +121,7 @@ func (s *Service) LogoutUser(ctx context.Context, userID *wrapperspb.StringValue
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer s.panicHandler.HandlePanic()
|
||||
defer s.handlePanic()
|
||||
|
||||
if err := s.bridge.LogoutUser(context.Background(), userID.Value); err != nil {
|
||||
s.log.WithError(err).Error("Failed to log user out")
|
||||
@ -135,7 +135,7 @@ func (s *Service) RemoveUser(ctx context.Context, userID *wrapperspb.StringValue
|
||||
s.log.WithField("UserID", userID.Value).Debug("RemoveUser")
|
||||
|
||||
go func() {
|
||||
defer s.panicHandler.HandlePanic()
|
||||
defer s.handlePanic()
|
||||
|
||||
// remove preferences
|
||||
if err := s.bridge.DeleteUser(context.Background(), userID.Value); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user