Skip to content
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

Fetch snapshot by time #262

Merged
merged 3 commits into from
Jan 30, 2019
Merged

Fetch snapshot by time #262

merged 3 commits into from
Jan 30, 2019

Commits on Dec 3, 2018

  1. Fetch snapshot by time

    This change adds the ability fetch a snapshot by time. The motivation
    for this is that fetching a document by time is quite a "natural" way
    to think about document history, and allows us to - for example - fetch
    multiple documents as they were at a given time, without having to
    look up their exact version numbers first.
    
    We add a new `Connection.fetchSnapshotByTimestamp` method, which
    follows a very similar route to `Connection.fetchSnapshot`, and where
    possible, as much code is re-used as possible:
    
      - both methods use a subclassed child of `SnapshotRequest`
      - both methods have their requests handled by the same machinery in
        `Connection`
      - both methods in the `Backend` have ops applied by a common method,
        but use their own methods for calls to middleware
    
    In order to make this feature possible at scale, this change also adds
    two new methods to the `MilestoneDB` interface:
    
      - `getMilestoneSnapshotAtOrBeforeTime`
      - `getMilestoneSnapshotAtOrAfterTime`
    
    These methods are used to fetch milestone snapshots either side of the
    requested timestamp, which means we only need to fetch the ops between
    the two of them to reach the desired timestamp.
    
    In the case where a milestone database is not being used, then fetching
    a snapshot by timestamp is still possible, but it will fetch all the ops
    for a document, and keep applying them from v0 until the timestamp is
    reached, which is not particularly scalable.
    Alec Gibson committed Dec 3, 2018
    Configuration menu
    Copy the full SHA
    4a7a178 View commit details
    Browse the repository at this point in the history

Commits on Jan 23, 2019

  1. Simplify shouldBreak calls for fetching snapshots by timestamp

    This change removes or renames `shouldBreak` calls. In `Backend`, for
    clarity we instead pre-filter ops, and just pass around the ops we want
    to be applied to a snapshot.
    
    In the `MemoryMilestoneDB`, these functions are extracted and renamed to
    more descriptive break condition names.
    Alec Gibson committed Jan 23, 2019
    Configuration menu
    Copy the full SHA
    579b22c View commit details
    Browse the repository at this point in the history
  2. Move snapshot building function into ot

    The function for building a snapshot from ops is useful, and has no
    dependencies on `Backend`. This change moves it into the `ot` module,
    where it will be a bit more discoverable and can be reused.
    Alec Gibson committed Jan 23, 2019
    Configuration menu
    Copy the full SHA
    8e46271 View commit details
    Browse the repository at this point in the history