public NEventStoreServer(IPersistStreams persistStreams) { var bootstrapper = new NEventStoreBootstrapper(persistStreams); _owinEmbeddedHost = OwinEmbeddedHost.Create(app => app.UseNancy(options => options.Bootstrapper = bootstrapper)); }
private static IDispatchCommits BuildDispatcher(IPersistStreams persistence) { return new AsynchronousDispatcher( new DelegateMessagePublisher(DispatchCommit), persistence, OnDispatchError); }
public PollingClientRx(IPersistStreams persistStreams, int pollingInterval = 1000, CancellationToken cancellationToken = default) { if (persistStreams == null) { throw new ArgumentNullException(nameof(persistStreams)); } if (pollingInterval <= 0) { throw new ArgumentException("Must be greater than 0", nameof(pollingInterval)); } _subject = new Subject <ICommit>(); _pollingClient2 = new PollingClient2(persistStreams, c => { if (cancellationToken.IsCancellationRequested) { _subject.OnCompleted(); return(PollingClient2.HandlingResult.Stop); } _subject.OnNext(c); return(PollingClient2.HandlingResult.MoveToNext); }, waitInterval: pollingInterval); }
public static Commit CommitSingle(this IPersistStreams persistence, string streamId = null) { Commit commit = (streamId ?? Guid.NewGuid().ToString()).BuildAttempt(); persistence.Commit(commit); return(commit); }
public PollingObserveCommits(IPersistStreams persistStreams, int interval, string bucketId, string checkpointToken = null) { _persistStreams = persistStreams; _checkpointToken = checkpointToken; _interval = interval; _bucketId = bucketId; }
public AsynchronousDispatcher(IPublishMessages bus, IPersistStreams persistence) { this.bus = bus; this.persistence = persistence; this.Start(); }
public static Task <ICommit> CommitSingleAsync( this IPersistStreams persistence, string streamId, CancellationToken cancellationToken) { var commitAttempt = (streamId ?? Guid.NewGuid().ToString()).BuildAttempt(); return(persistence.CommitAsync(commitAttempt, cancellationToken)); }
public static Commit CommitNext(this IPersistStreams persistence, Commit previous) { Commit commit = previous.BuildNextAttempt(); persistence.Commit(commit); return(commit); }
public ActivityProjector( IDbService dbService, IPersistStreams persistStreams, IEntryService entryService, IUserService userService, ILogger <ActivityProjector> logger, IOptions <Configuration> applicationConfiguration) : base(persistStreams, dbService) { var conventionalDispatcher = new ConventionBasedEventDispatcher(c => Checkpoint = c.ToSome(), commit => { logger.LogWarning($"Commit contains null events. CommitId:{commit.CommitId}, CommitSequence:{commit.CommitSequence}, StreamId:{commit.StreamId}, StreamRevision:{commit.StreamRevision}, EventCount:{commit.Events.Count}, AggregateId {commit.AggregateId()}"); }) .FirstProject <EntryCreated>(OnEntryCreated) .ThenProject <EntryUpdated>(OnEntryUpdated) .ThenProject <EntryRemoved>(OnEntryRemoved) .ThenProject <PlacementCreated>(OnPlacementCreated) .ThenProject <PlacementUpdated>(OnPlacementUpdated) .ThenProject <PlacementRemoved>(OnPlacementRemoved) .ThenProject <SkillSelfAssessmentCreated>(OnSelfAssessmentCreated) .ThenProject <SkillSelfAssessmentUpdated>(OnSelfAssessmentUpdated) .ThenProject <SkillSelfAssessmentRemoved>(OnSelfAssessmentRemoved) .ThenProject <EntryShared>(OnEntryShared) .ThenProject <EntryCollaboratorRemoved>(OnEntryCollaboratorRemoved) .ThenProject <EntryCommentCreated>(OnEntryCommentCreated); _conventionProjector = new ConventionBasedCommitProjecter(this, dbService, conventionalDispatcher); _entryService = entryService; _userService = userService; _applicationConfiguration = applicationConfiguration; }
/// <summary> /// /// </summary> /// <param name="persistStreams"></param> /// <param name="callback"></param> /// <param name="waitInterval">Interval in Milliseconds to wait when the provider /// return no more commit and the next request</param> public PollingClient2(IPersistStreams persistStreams, Func <ICommit, HandlingResult> callback, Int32 waitInterval = 100) { if (persistStreams == null) { throw new ArgumentNullException("PersistStreams cannot be null", "persistStreams"); } if (callback == null) { throw new ArgumentNullException("Cannot use polling client without callback", "callback"); } _logger = LogFactory.BuildLogger(GetType()); _waitInterval = waitInterval; _pollingWakeUpTimer = new System.Timers.Timer(); _pollingWakeUpTimer.Elapsed += (sender, e) => WakeUpPoller(); _pollingWakeUpTimer.Interval = _waitInterval; //Create polling thread _pollingThread = new Thread(InnerPollingLoop); _pollingThread.Start(); _commitCallback = callback; _persistStreams = persistStreams; _lastActivityTimestamp = DateTime.UtcNow; }
public SynchronousDispatcher(IPublishMessages bus, IPersistStreams persistence) { this.bus = bus; this.persistence = persistence; this.Start(); }
public SynchronousDispatchScheduler(IDispatchCommits dispatcher, IPersistStreams persistence) { _dispatcher = dispatcher; _persistence = persistence; Logger.Info(Resources.StartingDispatchScheduler); }
private static IDispatchCommits BuildDispatcher(IPersistStreams persistence, ILifetimeScope container) { return new AsynchronousDispatcher( new DelegateMessagePublisher(c => DispatchCommit(container, c)), persistence, OnDispatchError); }
public static Task <ICommit> CommitNextAsync( this IPersistStreams persistence, CommitAttempt previous, CancellationToken cancellationToken) { var nextAttempt = previous.BuildNextAttempt(); return(persistence.CommitAsync(nextAttempt, cancellationToken)); }
public static Task <ICommit> CommitSingle(this IPersistStreams persistence, string streamId = null, DateTime?now = null) { CommitAttempt commitAttempt = (streamId ?? Guid.NewGuid().ToString()) .BuildAttempt(now: now); return(persistence.Commit(commitAttempt)); }
public EventUnwinder( ProjectionEngineConfig config, ILogger logger) { _config = config; _logger = logger; _eventStore = Wireup .Init() .LogTo(t => new NEventStoreLog4NetLogger(_logger)) .UsingMongoPersistence(() => _config.EventStoreConnectionString, new DocumentObjectSerializer()) .InitializeStorageEngine() .Build(); var url = new MongoUrl(_config.EventStoreConnectionString); var client = new MongoClient(url); _mongoDatabase = client.GetDatabase(url.DatabaseName); _persistStream = _eventStore.Advanced; _unwindedEventCollection = _mongoDatabase.GetCollection <UnwindedDomainEvent>("UnwindedEvents"); _unwindedEventCollection.Indexes.CreateOne( Builders <UnwindedDomainEvent> .IndexKeys .Ascending(ude => ude.CheckpointToken) .Ascending(ude => ude.EventSequence) .Ascending(ude => ude.EventType), new CreateIndexOptions() { Name = "ScanPrimary" } ); }
public PipelineHooksAwarePersistanceDecorator(IPersistStreams original, IEnumerable<IPipelineHook> pipelineHooks) { if (original == null) throw new ArgumentNullException("original"); if (pipelineHooks == null) throw new ArgumentNullException("pipelineHooks"); this.original = original; this.pipelineHooks = pipelineHooks; }
protected override void Context() { snapshot = new Snapshot(streamId, 1, "Snapshot"); persistence1 = Partitions.NewEventStoreWithPartition(); persistence2 = Partitions.NewEventStoreWithPartition(); persistence1.Commit(streamId.BuildAttempt()); }
/// <summary> /// Deletes a stream from the default bucket. /// </summary> /// <param name="persistStreams">The IPersistStreams instance.</param> /// <param name="streamId">The stream id to be deleted.</param> public static Task DeleteStream(this IPersistStreams persistStreams, string streamId) { if (persistStreams == null) { throw new ArgumentException("persistStreams is null"); } return(persistStreams.DeleteStream(Bucket.Default, streamId)); }
/// <summary> /// Gets all commits after from start checkpoint. /// </summary> /// <param name="persistStreams">The IPersistStreams instance.</param> public static IEnumerable <ICommit> GetFromStart(this IPersistStreams persistStreams) { if (persistStreams == null) { throw new ArgumentException("persistStreams is null"); } return(persistStreams.GetFrom(null)); }
/// <summary> /// Gets all commits on or after from the specified starting time from the default bucket. /// </summary> /// <param name="persistStreams">The IPersistStreams instance.</param> /// <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" /> public static IEnumerable <ICommit> GetFrom(this IPersistStreams persistStreams, DateTime start) { if (persistStreams == null) { throw new ArgumentException("persistStreams is null"); } return(persistStreams.GetFrom(Bucket.Default, start)); }
public JoesBrowsableEventStore(IPersistStreams streamStore) { if (!(streamStore is IPersistStreamsWithAbsoluteOrdering)) { throw new ArgumentException("The stream store must impement IPersistStreamsWithAbsoluteOrdering in order to be used with JoesBrowsableEventStore", "streamStore"); } _streamStore = (IPersistStreamsWithAbsoluteOrdering)streamStore; }
/// <summary> /// Gets all commits after from start checkpoint. /// </summary> /// <param name="persistStreams">The IPersistStreams instance.</param> public static IEnumerable <ICommit> GetFromStart(this IPersistStreams persistStreams) { if (persistStreams == null) { throw new ArgumentNullException(nameof(persistStreams)); } return(persistStreams.GetFrom(0)); }
protected override void Context() { persistence1 = Partitions.NewEventStoreWithPartition(); persistence2 = Partitions.NewEventStoreWithPartition(); persistence1.Commit(streamId.BuildAttempt()); persistence2.Commit(streamId.BuildAttempt()); }
public OptimisticEventStore(IPersistStreams persistence, IEnumerable<IPipelineHook> pipelineHooks) { if (persistence == null) throw new ArgumentNullException("persistence"); this.persistence = persistence; this.pipelineHooks = pipelineHooks ?? new IPipelineHook[0]; }
public static IEnumerable <ICommit> GetFromTo(this IPersistStreams persistStreams, DateTime start, DateTime end) { if (persistStreams == null) { throw new ArgumentNullException(nameof(persistStreams)); } return(persistStreams.GetFromTo(Bucket.Default, start, end)); }
/// <summary> /// /// </summary> /// <param name="persistStreams">IPersistStreams Required for when the projector falls behind the head commit and needs to catchup</param> /// <param name="dbService"></param> public ProjectorBase(IPersistStreams persistStreams, IDbService dbService) { _persistStreams = persistStreams; _dbService = dbService; ProjectorId = this.GetProjectorId(); Receive <CatchUpMessage>(msg => Received(msg)); Receive <OrderedCommitNotification>(msg => Received(msg)); }
public void Run(int maxEventsThreshold = 500) { log.Info("Rebuild snapshots. MaxEventsThreshold: " + maxEventsThreshold); IPersistStreams advanced = events.Advanced; var ids = advanced.GetStreamsToSnapshot(maxEventsThreshold).Select(e => new Guid(e.StreamId)).ToArray(); ids.AsParallel().ForAll(MakeSnapshot); }
/// <summary> /// Deletes a stream from the default bucket. /// </summary> /// <param name="persistStreams">The IPersistStreams instance.</param> /// <param name="streamId">The stream id to be deleted.</param> public static void DeleteStream(this IPersistStreams persistStreams, string streamId) { if (persistStreams == null) { throw new ArgumentNullException(nameof(persistStreams)); } persistStreams.DeleteStream(Bucket.Default, streamId); }
public AsynchronousDispatcher( IPublishMessages bus, IPersistStreams persistence, Action<Commit, Exception> handleException) { this.bus = bus; this.persistence = persistence; this.handleException = handleException ?? ((c, e) => { }); this.Start(); }
public CommitFilterPersistence( IPersistStreams inner, IEnumerable<IFilterCommitReads> readFilter, IEnumerable<IFilterCommitWrites> writeFilter) { this.inner = inner; this.readFilters = readFilter ?? new IFilterCommitReads[0]; this.writeFilters = writeFilter ?? new IFilterCommitWrites[0]; }
public BoundedContextModule(IPersistStreams persistStreams) : base("boundedcontexts") { Get["/", true] = async(_, __) => { string[] strings = await persistStreams.GetBoundedContexts(); return(Negotiate.WithModel(strings)); }; }
public EventStoreClient( IPersistStreams persistStreams, int pollingIntervalMilliseconds = DefaultPollingInterval) { _persistStreams = persistStreams; _retrieveTimer = Observable .Interval(TimeSpan.FromMilliseconds(pollingIntervalMilliseconds)) .Subscribe(_ => RetrieveNow()); }
/// <summary> /// Gets all commits after from start checkpoint. /// </summary> /// <param name="persistStreams">The IPersistStreams instance.</param> /// <param name="cancellationToken">The cancellation token.</param> public static Task <IEnumerable <ICommit> > GetFromStartAsync(this IPersistStreams persistStreams, CancellationToken cancellationToken) { if (persistStreams == null) { throw new ArgumentNullException(nameof(persistStreams)); } return(persistStreams.GetFromAsync(0, cancellationToken)); }
public virtual PersistenceWireup WithPersistence(IPersistStreams instance) { if (Logger.IsInfoEnabled) { Logger.Info(Messages.RegisteringPersistenceEngine, instance.GetType()); } With(instance); return(this); }
public NEventStoreAdapter(IPersistStreams eventStore, int cacheSize, TimeSpan pollInterval, int maxPageSize, Func <DateTime> getUtcNow) { this.eventStore = eventStore; this.pollInterval = pollInterval; this.maxPageSize = maxPageSize; this.getUtcNow = getUtcNow; transactionCacheByPreviousCheckpoint = new LruCache <long, Transaction>(cacheSize); }
protected override async Task Context() { _process1 = new AcceptanceTestMongoPersistenceFactory().Build(); await _process1.Initialize(); _commit1 = await _process1.Commit(Guid.NewGuid().ToString().BuildAttempt()); _process2 = new AcceptanceTestMongoPersistenceFactory().Build(); await _process2.Initialize(); }
public PollingObserveCommits(IPersistStreams persistStreams, int interval, string checkpointToken, ICommitEnhancer enhancer, bool boost, IConcurrentCheckpointTracker tracker) { _persistStreams = persistStreams; _checkpointToken = checkpointToken; _enhancer = enhancer; _interval = interval; _boost = boost; _tracker = tracker; }
public OptimisticEventStore(IPersistStreams persistence, IEnumerable<IPipelineHook> pipelineHooks) { if (persistence == null) { throw new ArgumentNullException("persistence"); } _pipelineHooks = pipelineHooks ?? new IPipelineHook[0]; _persistence = new PipelineHooksAwarePersistanceDecorator(persistence, pipelineHooks); }
public PollingClient(IPersistStreams persistStreams, int interval = 5000) : base(persistStreams) { if (persistStreams == null) { throw new ArgumentNullException("persistStreams"); } if (interval <= 0) { throw new ArgumentException(Messages.MustBeGreaterThanZero.FormatWith("interval")); } _interval = interval; }
public PerformanceCounterPersistenceEngine(IPersistStreams persistence, string instanceName) { _persistence = persistence; _counters = new PerformanceCounters(instanceName); }
public EventStore(IPersistStreams persistence) { Guard.NotNull(() => persistence); this._persistence = persistence; }
public InMemoryPersistenceEngineWithSerialization(ISerialize serializer) { this.underlying = new InMemoryPersistenceEngine(); this.serializer = serializer; }
public AsynchronousDispatchScheduler(IDispatchCommits dispatcher, IPersistStreams persistence) : base(dispatcher, persistence) { _queue = new BlockingCollection<ICommit>(new ConcurrentQueue<ICommit>(), BoundedCapacity); }
public virtual PersistenceWireup WithPersistence(IPersistStreams instance) { Logger.Debug(Messages.RegisteringPersistenceEngine, instance.GetType()); this.With(instance); return this; }
public StoreEventsMock MockAdvanced(IPersistStreams advanced) { Advanced = advanced; return this; }
public AsynchronousDispatchScheduler(IDispatchCommits dispatcher, IPersistStreams persistence) : base(dispatcher, persistence) {}
public OptimisticEventStore(IPersistStreams persistence, IDispatchCommits dispatcher) { this.persistence = persistence; this.dispatcher = dispatcher; }
protected ClientBase(IPersistStreams persistStreams) { _persistStreams = persistStreams; }
public virtual PersistenceWireup WithPersistence(IPersistStreams instance) { this.With(instance); return this; }
public OptimisticEventStore(IPersistStreams persistence, IEnumerable<IPipelineHook> pipelineHooks) { this.persistence = persistence; this.pipelineHooks = pipelineHooks ?? new IPipelineHook[0]; }