mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 11:16:04 +02:00
Add global-scoped (and other type-scoped) cursors
Expanding recurring billing events will require a global cursor as opposed to a Registry-scoped cursor, so this CL creates a more generic Cursor type and adds a dual-write for the old RegistryCursor (for both old and new styles) on save. We can then touch any stragglers using the UpdateCursorsCommand and simply drop the old RegistryCursor once all have been migrated. See [] for migration tracking. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=121706885
This commit is contained in:
parent
42139be99d
commit
87961fbb12
7 changed files with 342 additions and 4 deletions
|
@ -24,13 +24,17 @@ import com.googlecode.objectify.annotation.Id;
|
|||
import com.googlecode.objectify.annotation.Parent;
|
||||
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.common.Cursor;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** Shared entity type for per-TLD date cursors. */
|
||||
/** Shared entity for per-TLD date cursors. */
|
||||
@Entity
|
||||
public class RegistryCursor extends ImmutableObject {
|
||||
|
||||
// TODO(b/28386088): Drop this class once all registry cursors have been saved in parallel as
|
||||
// new-style Cursors (either through business-as-usual operations or UpdateCursorsCommand).
|
||||
|
||||
/** The types of cursors, used as the string id field for each cursor in datastore. */
|
||||
public enum CursorType {
|
||||
/** Cursor for ensuring rolling transactional isolation of BRDA staging operation. */
|
||||
|
@ -80,6 +84,10 @@ public class RegistryCursor extends ImmutableObject {
|
|||
/** Convenience shortcut to save a cursor. */
|
||||
public static void save(Registry registry, CursorType cursorType, DateTime value) {
|
||||
ofy().save().entity(create(registry, cursorType, value));
|
||||
// In parallel, save the new cursor type alongside the old.
|
||||
ofy()
|
||||
.save()
|
||||
.entity(Cursor.create(Cursor.CursorType.valueOf(cursorType.name()), value, registry));
|
||||
}
|
||||
|
||||
/** Creates a new cursor instance. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue