99a9e14caaf54d884dac6a520111cfc8849d8323Timo Sirainen /* dsync state for incremental syncing */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen /* last time this user's state was updated */
f3e77a037a7ceef76d0d45432fb58c003dd61b32Timo Sirainen /* last_fast_sync is always >= last_full_sync. */
69c92cbe74dceb292f3de381edd39958ece148ebTimo Sirainen time_t last_fast_sync, last_full_sync, last_successful_sync;
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen /* User isn't currently in replication queue */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen /* Last replication sync failed */
f57e4c0f2824b93d09d7634974a7e2a47cb8ee0eTimo Sirainen /* Force a full sync on the next replication */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainentypedef void replicator_sync_callback_t(bool success, void *context);
f3e77a037a7ceef76d0d45432fb58c003dd61b32Timo Sirainenreplicator_queue_init(unsigned int full_sync_interval,
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenvoid replicator_queue_deinit(struct replicator_queue **queue);
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen/* Call the specified callback when data is added/removed/moved in queue
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen via _add(), _add_sync() or _remove() functions (not push/pop). */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenvoid replicator_queue_set_change_callback(struct replicator_queue *queue,
9b2129d5bdda49de45bc2f1e6160b2de338e0976Timo Sirainen/* Reference the user */
9b2129d5bdda49de45bc2f1e6160b2de338e0976Timo Sirainenvoid replicator_user_ref(struct replicator_user *user);
9b2129d5bdda49de45bc2f1e6160b2de338e0976Timo Sirainen/* Unreference the user. Returns TRUE if refcount is still >0. */
9b2129d5bdda49de45bc2f1e6160b2de338e0976Timo Sirainenbool replicator_user_unref(struct replicator_user **user);
ee8d619694b0b96ba2a8b603468147ce3e12b886Timo Sirainen/* Lookup an existing user */
ee8d619694b0b96ba2a8b603468147ce3e12b886Timo Sirainenreplicator_queue_lookup(struct replicator_queue *queue, const char *username);
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen/* Add a user to queue and return it. If the user already exists, it's updated
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen only if the new priority is higher. */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenreplicator_queue_add(struct replicator_queue *queue, const char *username,
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenvoid replicator_queue_add_sync(struct replicator_queue *queue,
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen/* Remove user from replication queue and free it. */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenvoid replicator_queue_remove(struct replicator_queue *queue,
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen/* Return the next user from replication queue, and remove it from the queue.
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen If there's nothing to be replicated currently, returns NULL and sets
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen next_secs_r to when there should be more work to do. */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenreplicator_queue_pop(struct replicator_queue *queue,
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen unsigned int *next_secs_r);
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen/* Add user back to queue. */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenvoid replicator_queue_push(struct replicator_queue *queue,
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenint replicator_queue_import(struct replicator_queue *queue, const char *path);
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenint replicator_queue_export(struct replicator_queue *queue, const char *path);
5ca40db1f869421fc3798a304ad402834250ff50Timo Sirainen/* Returns TRUE if user replication can be started now, FALSE if not. When
5ca40db1f869421fc3798a304ad402834250ff50Timo Sirainen returning FALSE, next_secs_r is set to user's next replication time. */
5ca40db1f869421fc3798a304ad402834250ff50Timo Sirainenbool replicator_queue_want_sync_now(struct replicator_queue *queue,
5ca40db1f869421fc3798a304ad402834250ff50Timo Sirainen unsigned int *next_secs_r);
b5ffdf79df3d9ace5a7c1fc08bb2b1d177157a01Timo Sirainen/* Iterate through all users in the queue. */
b5ffdf79df3d9ace5a7c1fc08bb2b1d177157a01Timo Sirainenreplicator_queue_iter_init(struct replicator_queue *queue);
b5ffdf79df3d9ace5a7c1fc08bb2b1d177157a01Timo Sirainenreplicator_queue_iter_next(struct replicator_queue_iter *iter);
b5ffdf79df3d9ace5a7c1fc08bb2b1d177157a01Timo Sirainenvoid replicator_queue_iter_deinit(struct replicator_queue_iter **iter);