Exemplo n.º 1
0
        public SqliteStreamStoreFixture()
        {
            var connectionString = $"Data Source={System.IO.Path.GetTempFileName()};Cache=Shared;";

            _settings = new SqliteStreamStoreSettings(connectionString)
            {
                GetUtcNow = () => GetUtcNow(),
            };
        }
Exemplo n.º 2
0
        public SqliteStreamStore(SqliteStreamStoreSettings settings)
            : base(settings.MetadataMaxAgeCacheExpire,
                   settings.MetadataMaxAgeCacheMaxSize,
                   settings.GetUtcNow,
                   settings.LogName)
        {
            _settings = settings;
            SqliteCommandExtensions.WithSettings(settings);

            _streamStoreNotifier = new Lazy <IStreamStoreNotifier>(() =>
            {
                if (_settings.CreateStreamStoreNotifier == null)
                {
                    throw new InvalidOperationException(
                        "Cannot create notifier because supplied createStreamStoreNotifier was null");
                }

                return(settings.CreateStreamStoreNotifier.Invoke(this));
            });

            _resolveNextVersion = (messages, direction, currentVersion) =>
            {
                if (messages.Any())
                {
                    var mVers = messages.Last().StreamVersion;
                    mVers = direction == ReadDirection.Forward
                        ? mVers + 1
                        : mVers < StreamVersion.Start ? StreamVersion.Start : mVers - 1;

                    return(mVers);
                }

                currentVersion = direction == ReadDirection.Forward
                    ? currentVersion + 1
                    : currentVersion == StreamVersion.End ? StreamVersion.End : currentVersion - 1;

                return(currentVersion);
            };
        }
Exemplo n.º 3
0
 public AllStreamOperations(SqliteConnection connection, SqliteStreamStoreSettings settings)
 {
     _connection = connection;
     _settings   = settings;
 }
Exemplo n.º 4
0
 public static void WithSettings(SqliteStreamStoreSettings settings) => _settings = settings;