Example #1
0
 public void Setup()
 {
     persister = new OutboxPersister(
         connectionBuilder: dbConnection,
         tablePrefix: $"{GetTablePrefix()}_",
         schema: schema,
         sqlVariant: sqlVariant.Convert(),
         cleanupBatchSize: 5);
     using (var connection = dbConnection())
     {
         connection.Open();
         connection.ExecuteCommand(OutboxScriptBuilder.BuildDropScript(sqlVariant), GetTablePrefix(), schema: schema);
         connection.ExecuteCommand(OutboxScriptBuilder.BuildCreateScript(sqlVariant), GetTablePrefix(), schema: schema);
     }
 }
    public void Setup()
    {
        dbConnection = GetConnection();
        tablePrefix  = GetTablePrefix();
        persister    = new SubscriptionPersister(
            connectionBuilder: dbConnection,
            tablePrefix: $"{tablePrefix}_",
            sqlVariant: sqlVariant.Convert(),
            schema: schema,
            cacheFor: TimeSpan.FromSeconds(10)
            );

        using (var connection = dbConnection())
        {
            connection.Open();
            connection.ExecuteCommand(SubscriptionScriptBuilder.BuildDropScript(sqlVariant), tablePrefix, schema: schema);
            connection.ExecuteCommand(SubscriptionScriptBuilder.BuildCreateScript(sqlVariant), tablePrefix, schema: schema);
        }
    }
    TimeoutPersister Setup(TimeSpan?cleanupInterval = null)
    {
        var name = GetTablePrefix();

        using (var connection = dbConnection())
        {
            connection.Open();
            connection.ExecuteCommand(TimeoutScriptBuilder.BuildDropScript(sqlVariant), name, schema: schema);
            connection.ExecuteCommand(TimeoutScriptBuilder.BuildCreateScript(sqlVariant), name, schema: schema);
        }

        var preventCleanupInterval = DateTime.UtcNow - new DateTime() + TimeSpan.FromDays(1); //Prevents entering cleanup mode right away (load timeouts from beginning of time)

        return(new TimeoutPersister(
                   connectionBuilder: dbConnection,
                   tablePrefix: $"{name}_",
                   sqlVariant: sqlVariant.Convert(),
                   schema: schema,
                   timeoutsCleanupExecutionInterval: cleanupInterval ?? preventCleanupInterval));
    }
    SagaPersister SetUp(string endpointName)
    {
        var runtimeSqlVariant = sqlVariant.Convert();

#pragma warning disable 618
        var commandBuilder = new SagaCommandBuilder(runtimeSqlVariant);
#pragma warning restore 618

        var sagaMetadataCollection = new SagaMetadataCollection();
        sagaMetadataCollection.Initialize(GetSagasAndFinders());

        var infoCache = new SagaInfoCache(
            versionSpecificSettings: null,
            jsonSerializer: Serializer.JsonSerializer,
            commandBuilder: commandBuilder,
            readerCreator: reader => new JsonTextReader(reader),
            writerCreator: writer => new JsonTextWriter(writer),
            tablePrefix: $"{endpointName}_",
            schema: schema,
            sqlVariant: runtimeSqlVariant,
            metadataCollection: sagaMetadataCollection,
            nameFilter: sagaName => sagaName);
        return(new SagaPersister(infoCache, runtimeSqlVariant));
    }