public SQLServerJournalDefaultConfigSpec(ITestOutputHelper outputHelper, SqlServerFixture fixture) : base(Initialize(fixture), "SQLServer-default", outputHelper) { var connFactory = new AkkaPersistenceDataConnectionFactory(new JournalConfig(conf.GetConfig("akka.persistence.journal.linq2db"))); using (var conn = connFactory.GetConnection()) { try { conn.GetTable <JournalRow>().Delete(); } catch (Exception e) { } try { conn.GetTable <JournalMetaData>().Delete(); } catch (Exception e) { } } Initialize(); }
RetrieveNextBatch() { Seq < Util.Try <ReplayCompletion> > msg; using (var conn = _connectionFactory.GetConnection()) { msg = await Messages(conn, persistenceId, opt.Item1, toSequenceNr, batchSize) .RunWith( ExtSeq.Seq <Util.Try <ReplayCompletion> >(), mat); } var hasMoreEvents = msg.Count == batchSize; //var lastMsg = msg.IsEmpty.LastOrDefault(); Util.Option <long> lastSeq = Util.Option <long> .None; if (msg.IsEmpty == false) { lastSeq = msg.Last.Get().Repr.SequenceNr; } FlowControlEnum nextControl = FlowControlEnum.Unknown; if ((lastSeq.HasValue && lastSeq.Value >= toSequenceNr) || opt.Item1 > toSequenceNr) { nextControl = FlowControlEnum.Stop; } else if (hasMoreEvents) { nextControl = FlowControlEnum.Continue; } else if (refreshInterval.HasValue == false) { nextControl = FlowControlEnum.Stop; } else { nextControl = FlowControlEnum.ContinueDelayed; } long nextFrom = opt.Item1; if (lastSeq.HasValue) { nextFrom = lastSeq.Value + 1; } return new Util.Option <((long, FlowControlEnum), Seq <Util.Try <ReplayCompletion> >)>(( (nextFrom, nextControl), msg)); }
public DockerLinq2DbSqlServerJournalPerfSpec(ITestOutputHelper output, SqlServerFixture fixture) : base(InitConfig(fixture), "sqlserverperf", output, 40, eventsCount: TestConstants.DockerNumMessages) { var connFactory = new AkkaPersistenceDataConnectionFactory(new JournalConfig(Create(DockerDbUtils.ConnectionString).GetConfig("akka.persistence.journal.testspec"))); using (var conn = connFactory.GetConnection()) { try { conn.GetTable <JournalRow>().Delete(); } catch (Exception e) { } } }
public DockerLinq2DbPostgreSqlSqlCommonJournalCompatibilitySpec(ITestOutputHelper output, PostgreSQLFixture fixture) : base(output) { //DebuggingHelpers.SetupTraceDump(output); Config = InitConfig(fixture); var connFactory = new AkkaPersistenceDataConnectionFactory(new JournalConfig(Create(DockerDbUtils.ConnectionString).GetConfig("akka.persistence.journal.testspec"))); using (var conn = connFactory.GetConnection()) { try { conn.GetTable <JournalRow>().Delete(); } catch (Exception e) { } } }
public DockerLinq2DbPostgreSQLJournalSpec(ITestOutputHelper output, PostgreSQLFixture fixture) : base(InitConfig(fixture), "postgresperf", output) { var connFactory = new AkkaPersistenceDataConnectionFactory(new JournalConfig(Create(DockerDbUtils.ConnectionString).GetConfig("akka.persistence.journal.testspec"))); using (var conn = connFactory.GetConnection()) { try { conn.GetTable <JournalRow>().Delete(); } catch (Exception e) { } } Initialize(); }
public MSSQLiteLinq2DbJournalPerfSpec(ITestOutputHelper output) : base(SQLiteJournalSpecConfig.Create(connString, ProviderName.SQLiteMS), "SqliteJournalSpec", output, eventsCount: TestConstants.NumMessages) { heldSqliteConnection.Open(); //InitWALForFileDb(); var conf = new JournalConfig( SQLiteJournalSpecConfig.Create(connString, ProviderName.SQLiteMS).GetConfig("akka.persistence.journal.testspec")); var connFactory = new AkkaPersistenceDataConnectionFactory(conf); using (var conn = connFactory.GetConnection()) { try { conn.GetTable <JournalRow>().Delete(); } catch (Exception e) { } } }
public SQLServerSnapshotSpec(ITestOutputHelper outputHelper, SqlServerFixture fixture) : base(Initialize(fixture)) { DebuggingHelpers.SetupTraceDump(outputHelper); var connFactory = new AkkaPersistenceDataConnectionFactory( new SnapshotConfig( conf.GetConfig("akka.persistence.snapshot-store.linq2db"))); using (var conn = connFactory.GetConnection()) { try { conn.GetTable <SnapshotRow>().Delete(); } catch (Exception e) { } } Initialize(); }
RetrieveNextBatch() { Seq < Util.Try <ReplayCompletion> > msg; using (var conn = _connectionFactory.GetConnection()) { var waited = Messages(conn, persistenceId, opt.Item1, toSequenceNr, batchSize); msg = await waited .RunWith( ExtSeq.Seq <Util.Try <ReplayCompletion> >(), mat); } var hasMoreEvents = msg.Count == batchSize; var lastMsg = msg.LastOrDefault(); Util.Option <long> lastSeq = Util.Option <long> .None; if (lastMsg != null && lastMsg.IsSuccess) { lastSeq = lastMsg.Success.Select(r => r.repr.SequenceNr); } else if (lastMsg != null && lastMsg.Failure.HasValue) { throw lastMsg.Failure.Value; } var hasLastEvent = lastSeq.HasValue && lastSeq.Value >= toSequenceNr; FlowControl nextControl = null; if (hasLastEvent || opt.Item1 > toSequenceNr) { nextControl = FlowControl.Stop.Instance; } else if (hasMoreEvents) { nextControl = FlowControl.Continue.Instance; } else if (refreshInterval.HasValue == false) { nextControl = FlowControl.Stop.Instance; } else { nextControl = FlowControl.ContinueDelayed .Instance; } long nextFrom = 0; if (lastSeq.HasValue) { nextFrom = lastSeq.Value + 1; } else { nextFrom = opt.Item1; } return(new Util.Option <((long, FlowControl), Seq <Util.Try <ReplayCompletion> >)>(( (nextFrom, nextControl), msg))); }
public void InitializeTables() { using (var conn = _connectionFactory.GetConnection()) { try { conn.CreateTable <SnapshotRow>(); } catch (Exception e) { if (_snapshotConfig.TableConfig.WarnOnAutoInitializeFail) { _logger.Warning(e, $"Could not Create Snapshot Table {_snapshotConfig.TableConfig.TableName} as requested by config."); } } } }