Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

IStoreEvents is now vastly simplified by returning a reference to the…

… underlying persistence for use in more advanced scenarios.
  • Loading branch information...
commit 15afa02d8e2c034d2d592ace8e7309adfdc30bc2 1 parent 22be21a
Oliver, Jonathan authored
View
4 doc/EventStore.Example/MainProgram.cs
@@ -80,11 +80,11 @@ private static void AppendToStream()
private static void TakeSnapshot()
{
var memento = new AggregateMemento { Value = "snapshot" };
- store.AddSnapshot(new Snapshot(StreamId, 2, memento));
+ store.Advanced.AddSnapshot(new Snapshot(StreamId, 2, memento));
}
private static void LoadFromSnapshotForwardAndAppend()
{
- var latestSnapshot = store.GetSnapshot(StreamId, int.MaxValue);
+ var latestSnapshot = store.Advanced.GetSnapshot(StreamId, int.MaxValue);
using (var stream = store.OpenStream(latestSnapshot, int.MaxValue))
{
View
18 src/proj/EventStore.Core/OptimisticEventStore.cs
@@ -71,23 +71,9 @@ void ICommitEvents.Commit(Commit attempt)
hook.PostCommit(attempt);
}
- public virtual IEnumerable<Commit> GetFrom(DateTime started)
+ public virtual IPersistStreams Advanced
{
- return this.persistence.GetFrom(started);
- }
-
- public virtual Snapshot GetSnapshot(Guid streamId, int maxRevision)
- {
- maxRevision = maxRevision <= 0 ? int.MaxValue : maxRevision;
- return this.persistence.GetSnapshot(streamId, maxRevision); // TODO: add to some kind of cache
- }
- public virtual bool AddSnapshot(Snapshot snapshot)
- {
- return this.persistence.AddSnapshot(snapshot); // TODO: update the cache here
- }
- public virtual IEnumerable<StreamHead> GetStreamsToSnapshot(int maxThreshold)
- {
- return this.persistence.GetStreamsToSnapshot(maxThreshold);
+ get { return this.persistence; }
}
}
}
View
11 src/proj/EventStore/IStoreEvents.cs
@@ -1,7 +1,6 @@
namespace EventStore
{
using System;
- using System.Collections.Generic;
using Persistence;
/// <summary>
@@ -10,7 +9,7 @@ namespace EventStore
/// <remarks>
/// Instances of this class must be designed to be multi-thread safe such that they can be shared between threads.
/// </remarks>
- public interface IStoreEvents : IDisposable, IAccessSnapshots
+ public interface IStoreEvents : IDisposable
{
/// <summary>
/// Creates a new stream.
@@ -43,12 +42,8 @@ public interface IStoreEvents : IDisposable, IAccessSnapshots
IEventStream OpenStream(Snapshot snapshot, int maxRevision);
/// <summary>
- /// Gets all commits on or after from the specified starting time.
+ /// Gets a reference to the underlying persistence engine which allows direct access to persistence operations.
/// </summary>
- /// <param name="start">The point in time at which to start.</param>
- /// <returns>All commits that have occurred on or after the specified starting time.</returns>
- /// <exception cref="StorageException" />
- /// <exception cref="StorageUnavailableException" />
- IEnumerable<Commit> GetFrom(DateTime start);
+ IPersistStreams Advanced { get; }
}
}
View
7 src/tests/EventStore.Core.UnitTests/OptimisticEventStoreTests.cs
@@ -351,6 +351,13 @@ public class when_a_precommit_hook_rejects_a_commit : using_persistence
}
[Subject("OptimisticEventStore")]
+ public class when_accessing_the_underlying_persistence : using_persistence
+ {
+ It should_return_a_reference_to_the_underlying_persistence_infrastructure = () =>
+ store.Advanced.ShouldBeTheSameAs(persistence.Object);
+ }
+
+ [Subject("OptimisticEventStore")]
public class when_disposing_the_event_store : using_persistence
{
Because of = () =>
Please sign in to comment.
Something went wrong with that request. Please try again.