Esempio n. 1
0
        /// <summary>
        /// Creates an adapter that observes an implementation of <see cref="IPassiveEventStore"/> and efficiently handles
        /// multiple subscribers.
        /// </summary>
        /// <param name="eventStore">
        /// The persistency implementation that the NEventStore is configured with.
        /// </param>
        /// <param name="cacheSize">
        /// The size of the LRU cache that will hold transactions already loaded from the event store. The larger the cache,
        /// the higher the chance multiple subscribers can reuse the same transactions without hitting the underlying event store.
        /// Set to <c>0</c> to disable the cache alltogether.
        /// </param>
        /// <param name="pollInterval">
        /// The amount of time to wait before polling again after the event store has not yielded any transactions anymore.
        /// </param>
        /// <param name="maxPageSize">
        /// The size of the page of transactions the adapter should load from the event store for every query.
        /// </param>
        /// <param name="getUtcNow">
        /// Provides the current date and time in UTC.
        /// </param>
        public PollingEventStoreAdapter(IPassiveEventStore eventStore, int cacheSize, TimeSpan pollInterval, int maxPageSize,
                                        Func <DateTime> getUtcNow)
        {
            this.eventStore   = eventStore;
            this.pollInterval = pollInterval;
            this.maxPageSize  = maxPageSize;
            this.getUtcNow    = getUtcNow;

            if (cacheSize > 0)
            {
                transactionCacheByPreviousCheckpoint = new LruCache <long, Transaction>(cacheSize);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an adapter that observes an implementation of <see cref="IPassiveEventStore"/> and efficiently handles
        /// multiple subscribers.
        /// </summary>
        /// <param name="eventStore">
        /// The persistency implementation that the NEventStore is configured with.
        /// </param>
        /// <param name="cacheSize">
        /// The size of the LRU cache that will hold transactions already loaded from the event store. The larger the cache,
        /// the higher the chance multiple subscribers can reuse the same transactions without hitting the underlying event store.
        /// Set to <c>0</c> to disable the cache alltogether.
        /// </param>
        /// <param name="pollInterval">
        /// The amount of time to wait before polling again after the event store has not yielded any transactions anymore.
        /// </param>
        /// <param name="maxPageSize">
        /// The size of the page of transactions the adapter should load from the event store for every query.
        /// </param>
        /// <param name="getUtcNow">
        /// Obsolete. Only kept in there to prevent breaking changes.
        /// </param>
        /// <param name="logger">
        /// An optional method for logging internal diagnostic messages as well as any exceptions that happen.
        /// </param>
        /// <remarks>
        /// Diagnostic information is only logged if this code is compiled with the LIQUIDPROJECTIONS_DIAGNOSTICS compiler symbol.
        /// </remarks>
        public PollingEventStoreAdapter(IPassiveEventStore eventStore, int cacheSize, TimeSpan pollInterval, int maxPageSize,
                                        Func <DateTime> getUtcNow, LogMessage logger = null)
        {
            this.eventStore   = eventStore;
            this.pollInterval = pollInterval;
            this.maxPageSize  = maxPageSize;

#if LIQUIDPROJECTIONS_DIAGNOSTICS
            this.logDebug = logger ?? (_ =>
            {
            });
#else
            this.logDebug = _ => {};
#endif
            this.logError = logger ?? (_ =>
            {
            });

            if (cacheSize > 0)
            {
                cachedTransactionsByPrecedingCheckpoint = new LruCache <long, Transaction>(cacheSize);
            }
        }