Implementation of the new sync service that interleaves syncing jobs for
all active users.
It also includes improvements to the message downloader. The download
will now auto rate limit the parallel workers based on the server
responses.
Additionally each of the stages is now tested in isolation to ensure the
behavior matches the expectations.
Finally, this patch does not replace the existing IMAP sync. A follow up
patch is necessary to integrate the IMAP bits into the interfaces
required by these changes.
Rather than having the services subscribe to each individual event type,
have only one subscriber for the whole event object. This spreads the
logic to the service through the `EventHandler` type.
This is important for the next stage where the IMAP service will be
required to apply events from the past.
Identity Service contains all the information related to user state,
addresses and keys.
This patch also introduces the `State` type which can be used by other
services to maintain their own copy of this state to avoid lock
contention.
Finally, there are currently no external facing methods via a CPC
interface. Those will added as needed once the refactoring of the
architecture is complete.
This patch adds the User Event Service which is meant to replace the
current event polling flow.
Each user interested in receiving events should register a new
subscriber using the `Service.Subscribe` function and then react on
the incoming events.
The current patch does not hook this up Bridge user as there are no
existing consumers, but it does provide extensive testing for the
expected behavior.