Skip to content

Provide collection to SyncManager #881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 11, 2024

Conversation

sunkup
Copy link
Member

@sunkup sunkup commented Jul 3, 2024

Purpose

Provides database Collection to SyncManager. This is a prerequisite for #588 , #876 and #878

Short description

Provide collection to

  • CalendarSyncManager
  • ContactsSyncManager
  • JtxSyncManager
  • TasksSyncManager

by rewriting sync method in respective syncer classes
and finally provide collection to SyncManager.

Also:

  • adapt TestSyncManager

Checklist

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

@sunkup sunkup added the refactoring Internal improvement of existing functions label Jul 3, 2024
@sunkup sunkup self-assigned this Jul 3, 2024
@sunkup sunkup linked an issue Jul 3, 2024 that may be closed by this pull request
@sunkup sunkup changed the title Provide collection to CalendarSyncManager Provide collection to SyncManager Jul 3, 2024
@sunkup sunkup requested a review from ArnyminerZ July 3, 2024 14:18
@sunkup sunkup marked this pull request as ready for review July 3, 2024 14:18
Copy link
Member

@ArnyminerZ ArnyminerZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I like the new approach without that many sub-functions.

@rfc2822 rfc2822 force-pushed the 875-provide-database-collection-to-syncmanager branch from 8297806 to 42cb4cf Compare July 4, 2024 17:47
- added KDoc
- SyncManager can never handle address book authority (content
  authority for contacts is contacts authority)
- moved @UsesThreadContextClassLoader to respective sync manager
Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Do you think it would be possible to generalize the process of creating/updating/deleting collections, maybe with an interface or by having the code in `Syncer' and just provide implementation details in the sub-classes? Would be nice if the same code wouldn't be there three times.
  2. Can you please re-base/merge the latest changes? I changed the Syncers to use DI.

@sunkup
Copy link
Member Author

sunkup commented Jul 9, 2024

  1. Do you think it would be possible to generalize the process of creating/updating/deleting collections, maybe with an interface or by having the code in `Syncer' and just provide implementation details in the sub-classes? Would be nice if the same code wouldn't be there three times.

Maybe, I will see what I can do :)

@sunkup
Copy link
Member Author

sunkup commented Jul 10, 2024

It's hard.

I have divided the process into 5 stages:

  1. Preparations
  2. find resource lists (calendars/addressbooks/task lists) to be synced
  3. update/delete local resource lists
  4. create new local resources
  5. sync local resources contents

I tried dividing the process into smaller methods in their respective resource type syncers, which are then called one after another in the base syncer. This only makes the process more complicated and yields more duplicated code. Using an interface with decoratored classes only complicates everything even more.

The problem are the subtle differences between the resource types. I feel that the easiest way to combine all resource types in one process is to throw them all in one method (sync in base syncer) with a lot of if/else statements deciding the subtleties. It would complicate the sync process a little bit more, but we would get rid of the duplicated code and could drop the specific syncer implementations.

That is, we would have one (non-abstract) Syncer, which we'd supply with the authority to be synced. At the moment we also pass the authority to the sync method. So there might actually not be a good gain in having multiple different syncers.

I suggest we try merging the different sync step implementations of the syncers in the syncer, passing the authority along as construction argument and let this one concrete syncer instance handle the whole process for all resource types.

In a new PR though.

@rfc2822 What do you think? Maybe should have a call about it :)

@rfc2822
Copy link
Member

rfc2822 commented Jul 11, 2024

👍🏻 As discussed, to be followed up by #896

@rfc2822 rfc2822 merged commit 3d65afb into main-ose Jul 11, 2024
8 checks passed
@rfc2822 rfc2822 deleted the 875-provide-database-collection-to-syncmanager branch July 11, 2024 12:09
@rfc2822 rfc2822 mentioned this pull request Jul 13, 2024
6 tasks
@sunkup sunkup mentioned this pull request Jul 17, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Internal improvement of existing functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide database Collection to SyncManager
3 participants