Closed Bug 434812 Opened 17 years ago Closed 17 years ago

Add a property to engines for how much they need a sync

Categories

(Cloud Services :: General, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: hello, Assigned: anant)

References

Details

Attachments

(1 file)

The idea here is for the service to be able to ask each engine how "out of date" they think they are. That is, assuming engines have been listening for changes in their data stores, they could have an idea of the volume of changes they have queued up for the server. The property is not meant to directly reflect the volume of data, rather how much a sync is needed for that engine. This will allow the service to determine if the engine needs to be synced sooner rather than later.
I've been thinking this could be a number with well-defined boundaries, for example (0 100) where 0 means 'nothing to sync', and 100 means 'please sync me now asap'.
We could also store a multiplier for each engine. That would allow us to tweak how aggressively we sync certain data types without turning them off.
Blocks: 434816
No longer blocks: 433900
Priority: -- → P1
Target Milestone: -- → 0.2
Taking a look at this one...
Assignee: nobody → anarayanan
I've added a new 'Tracker' object that will be instantiated by the engine, and can be queried using the 'getScore' method to get a value between 0 and 100. This value will be set by the engine - either by overriding getScore, or updating the internal property in response to observers. The service can call this method every 'n' minutes to get an idea of whether the engine needs to be synced now, and then call resetScore after a sync for that engine (which simply sets the score back to 0). The patch includes an example implementation of the BookmarksTracker, which just assigns 4 points for each add/remove and 2 points for each change. These values may need to be adjusted after discussion.
Attachment #322180 - Flags: review?(thunder)
Comment on attachment 322180 [details] [diff] [review] Add support for engines to report their urgency to sync Very nice start. Comments: >diff -r 02f81585c4e5 modules/trackers.js >--- /dev/null Thu Jan 01 00:00:00 1970 +0000 >+++ b/modules/trackers.js Thu May 22 15:19:29 2008 -0700 >@@ -0,0 +1,140 @@ >+/* ***** BEGIN LICENSE BLOCK ***** >+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1 >+ * >+ * The contents of this file are subject to the Mozilla Public License Version >+ * 1.1 (the "License"); you may not use this file except in compliance with >+ * the License. You may obtain a copy of the License at >+ * http://www.mozilla.org/MPL/ >+ * >+ * Software distributed under the License is distributed on an "AS IS" basis, >+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License >+ * for the specific language governing rights and limitations under the >+ * License. >+ * >+ * The Original Code is Bookmarks Sync. >+ * >+ * The Initial Developer of the Original Code is Mozilla. >+ * Portions created by the Initial Developer are Copyright (C) 2007 >+ * the Initial Developer. All Rights Reserved. >+ * >+ * Contributor(s): >+ * Dan Mills <thunder@mozilla.com> Hey, I think you should be there instead of me ;) ... >+/* >+ * Trackers are associated with a single engine and deal with >+ * listening for changes to their particular data type >+ * and updating their 'score', indicating how urgently they >+ * want to sync. >+ * >+ * 'score's range from 0 (Nothing's changed) >+ * to 100 (I need to sync now!) Myk and I were discussing the possibility yesterday of -1 being valid. It would mean "don't sync me unless the user specifically requests it". This would make sense for tabs & windows, which won't be synced by default except at very specific events (shutdown & specific user action). ... >+ getScore: function T_getScore() { >+ if (this._score >= 100) >+ return 100; >+ else >+ return this._score; >+ }, How about a getter instead? get score() { ... }, It's nicer than a method in this case. Otherwise I like it. r+.
Attachment #322180 - Flags: review?(thunder) → review+
Checked-in revision 359. I'll file bugs for other engines to add support for trackers.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Component: Weave → General
Product: Mozilla Labs → Weave
QA Contact: weave → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: