feat(GODT-2848): Decouple IMAP service from Event Loop

The IMAP service no longer blocks the event loop from progressing. When
syncing the event loop continues as usual, allow other parts of the
bridge to continue updating.

Once the sync is complete, it resets the event id back to the last
handled id before sync started and then we play catch up.
This commit is contained in:
Leander Beernaert
2023-08-30 10:51:53 +02:00
parent dd7db00f74
commit a5a9bd762d
5 changed files with 372 additions and 46 deletions

View File

@ -295,7 +295,8 @@ func newImpl(
})
// Start Event Service
if err := user.eventService.Start(ctx, user.serviceGroup); err != nil {
lastEventID, err := user.eventService.Start(ctx, user.serviceGroup)
if err != nil {
return user, fmt.Errorf("failed to start event service: %w", err)
}
@ -311,7 +312,7 @@ func newImpl(
}
// Start IMAP Service
if err := user.imapService.Start(ctx, user.serviceGroup, syncService); err != nil {
if err := user.imapService.Start(ctx, user.serviceGroup, syncService, lastEventID); err != nil {
return user, fmt.Errorf("failed to start imap service: %w", err)
}