public static RavenStreamHead ToRavenStreamHead(this Snapshot snapshot) { return(new RavenStreamHead { Id = RavenStreamHead.GetStreamHeadId(snapshot.BucketId, snapshot.StreamId), BucketId = snapshot.BucketId, StreamId = snapshot.StreamId, HeadRevision = snapshot.StreamRevision, SnapshotRevision = snapshot.StreamRevision }); }
public static RavenStreamHead ToRavenStreamHead(this Commit commit) { return(new RavenStreamHead { Id = RavenStreamHead.GetStreamHeadId(commit.BucketId, commit.StreamId), BucketId = commit.BucketId, StreamId = commit.StreamId, HeadRevision = commit.StreamRevision, SnapshotRevision = 0 }); }
private void SaveStreamHeadAsync(RavenStreamHead updated) { TryRaven(() => { using (TransactionScope scope = OpenCommandScope()) using (IDocumentSession session = _store.OpenSession()) { RavenStreamHead current = session.Load <RavenStreamHead>(RavenStreamHead.GetStreamHeadId(updated.BucketId, updated.StreamId)) ?? updated; current.HeadRevision = updated.HeadRevision; if (updated.SnapshotRevision > 0) { current.SnapshotRevision = updated.SnapshotRevision; } session.Advanced.UseOptimisticConcurrency = false; session.Store(current); session.SaveChanges(); scope.Complete(); // if this fails it's no big deal, stream heads can be updated whenever } return(true); }); }