Exemple #1
0
 public CommentDao(IDbConnectionProvider conn,
     ICommentTreeBuilder commentTreeBuilder)
     : base(conn)
 {
     _conn = conn;
     _commentTreeBuilder = commentTreeBuilder;
 }
 /// <summary>
 /// Constructs the storage using the specified connection provider and table to store its subscriptions. If the subscription
 /// storage is shared by all subscribers and publishers, the <paramref name="isCentralized"/> parameter can be set to true
 /// in order to subscribe/unsubscribe directly instead of sending subscription/unsubscription requests
 /// </summary>
 public SqlServerSubscriptionStorage(IDbConnectionProvider connectionProvider, string tableName, bool isCentralized, IRebusLoggerFactory rebusLoggerFactory)
 {
     IsCentralized       = isCentralized;
     _log                = rebusLoggerFactory.GetCurrentClassLogger();
     _connectionProvider = connectionProvider;
     _tableName          = tableName;
 }
Exemple #3
0
        public SQLMessageQueue(IDbConnectionProvider connectionProvider, ISQLDialect dialect, QueueName queueName,
            IQueueListener listener, QueueOptions options = default(QueueOptions))
        {
            if (connectionProvider == null) throw new ArgumentNullException("connectionProvider");
            if (dialect == null) throw new ArgumentNullException("dialect");
            if (queueName == null) throw new ArgumentNullException("queueName");
            if (listener == null) throw new ArgumentNullException("listener");

            _connectionProvider = connectionProvider;
            _dialect = dialect;
            _queueName = queueName;

            _listener = listener;
            _autoAcknowledge = options.AutoAcknowledge;
            _maxAttempts = options.MaxAttempts <= 0 ? 10 : options.MaxAttempts;
            _retryDelay = options.RetryDelay < TimeSpan.Zero ? TimeSpan.Zero : options.RetryDelay;

            var concurrencyLimit = options.ConcurrencyLimit <= 0
                ? QueueOptions.DefaultConcurrencyLimit
                : options.ConcurrencyLimit;
            _concurrentMessageProcessingSlot = new SemaphoreSlim(concurrencyLimit);

            _cancellationTokenSource = new CancellationTokenSource();
            _queuedMessages = new BufferBlock<SQLQueuedMessage>(new DataflowBlockOptions
            {
                CancellationToken = _cancellationTokenSource.Token
            });
        }
Exemple #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="connectionProvider">A <see cref="IDbConnection"/> to obtain a database connection</param>
 /// <param name="tableName">Name of the table to store messages in</param>
 /// <param name="inputQueueName">Name of the queue this transport is servicing</param>
 /// <param name="rebusLoggerFactory">A <seealso cref="IRebusLoggerFactory"/> for building loggers</param>
 /// <param name="asyncTaskFactory">A <seealso cref="IAsyncTaskFactory"/> for creating periodic tasks</param>
 /// <param name="leaseInterval">Interval of time messages are leased for</param>
 /// <param name="leaseTolerance">Buffer to allow lease overruns by</param>
 /// <param name="leasedByFactory">Factory for generating a string which identifies who has leased a message (eg. A hostname)</param>
 /// <param name="automaticLeaseRenewalInterval">If non-<c>null</c> messages will be automatically re-leased after this time period has elapsed</param>
 public SqlServerLeaseTransport(
     IDbConnectionProvider connectionProvider,
     string tableName,
     string inputQueueName,
     IRebusLoggerFactory rebusLoggerFactory,
     IAsyncTaskFactory asyncTaskFactory,
     TimeSpan leaseInterval,
     TimeSpan?leaseTolerance,
     Func <string> leasedByFactory,
     TimeSpan?automaticLeaseRenewalInterval = null
     ) : base(connectionProvider, tableName, inputQueueName, rebusLoggerFactory, asyncTaskFactory)
 {
     _leasedByFactory            = leasedByFactory;
     _leaseIntervalMilliseconds  = (long)Math.Ceiling(leaseInterval.TotalMilliseconds);
     _leaseToleranceMilliseconds = (long)Math.Ceiling((leaseTolerance ?? TimeSpan.FromSeconds(15)).TotalMilliseconds);
     if (automaticLeaseRenewalInterval.HasValue == false)
     {
         _automaticLeaseRenewal = false;
     }
     else
     {
         _automaticLeaseRenewal = true;
         _automaticLeaseRenewalIntervalMilliseconds = (long)Math.Ceiling(automaticLeaseRenewalInterval.Value.TotalMilliseconds);
     }
 }
Exemple #5
0
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE subs ADD COLUMN created_by uuid NULL;");
     });
 }
Exemple #6
0
        protected DataTestBase()
            : base(new Skimur.App.Registrar(),
                new Skimur.App.Handlers.Registrar(),
                new Skimur.Markdown.Registrar(),
                new Skimur.Scraper.Registrar())
        {
            Monitor.Enter(_sync);

            _conn = _serviceProvider.GetService<IDbConnectionProvider>();

            // recreate the entire postgres database
            _conn.Perform(conn =>
            {
                conn.ExecuteSql("drop schema public cascade;create schema public;");
            });

            // recreate the entire cassandra keyspace
            using (var cassandraCluster = Cluster.Builder()
                .AddContactPoint(_serviceProvider.GetService<ICassandraConnectionStringProvider>().ConnectionString)
                .Build())
            {
                using (var cassandraConnection = cassandraCluster.Connect())
                {
                    cassandraConnection.DeleteKeyspaceIfExists("skimur");
                    cassandraConnection.CreateKeyspace("skimur");
                }
            }

            Cassandra.Migrations.Migrations.Run(_serviceProvider);
            Postgres.Migrations.Migrations.Run(_serviceProvider);
        }
Exemple #7
0
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE posts ADD COLUMN number_of_comments integer NOT NULL DEFAULT 0;");
     });
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="connectionProvider">A <see cref="IDbConnection"/> to obtain a database connection</param>
        /// <param name="lockTableName">Name of the queue this transport is servicing</param>
        /// <param name="rebusLoggerFactory">A <seealso cref="IRebusLoggerFactory"/> for building loggers</param>
        /// <param name="asyncTaskFactory">A <seealso cref="IAsyncTaskFactory"/> for creating periodic tasks</param>
        /// <param name="rebusTime">A <seealso cref="IRebusTime"/> to provide the current time</param>
        /// <param name="options">Additional options</param>
        public MySqlExclusiveAccessLock(
            IDbConnectionProvider connectionProvider,
            string lockTableName,
            IRebusLoggerFactory rebusLoggerFactory,
            IAsyncTaskFactory asyncTaskFactory,
            IRebusTime rebusTime,
            MySqlExclusiveAccessLockOptions options)
        {
            if (rebusLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(rebusLoggerFactory));
            }
            if (asyncTaskFactory == null)
            {
                throw new ArgumentNullException(nameof(asyncTaskFactory));
            }

            _rebusTime          = rebusTime ?? throw new ArgumentNullException(nameof(rebusTime));
            _connectionProvider = connectionProvider ?? throw new ArgumentNullException(nameof(connectionProvider));
            _lockTableName      = lockTableName != null?TableName.Parse(lockTableName) : null;

            _log = rebusLoggerFactory.GetLogger <MySqlExclusiveAccessLock>();
            _lockExpirationTimeout = options.LockExpirationTimeout ?? DefaultLockExpirationTimeout;

            var cleanupInterval = options.ExpiredLocksCleanupInterval ?? DefaultExpiredLocksCleanupInterval;
            var intervalSeconds = (int)cleanupInterval.TotalSeconds;

            _expiredLocksCleanupTask = asyncTaskFactory.Create("ExpiredLocksCleanup", PerformExpiredLocksCleanupCycle, intervalSeconds: intervalSeconds);
            _autoDeleteTable         = options.AutoDeleteTable;
        }
Exemple #9
0
        /// <summary>
        /// Constructs the saga storage, using the specified connection provider and tables for persistence.
        /// </summary>
		public SqlServerSagaStorage(IDbConnectionProvider connectionProvider, string dataTableName, string indexTableName, IRebusLoggerFactory rebusLoggerFactory)
        {
            _log = rebusLoggerFactory.GetCurrentClassLogger();
            _connectionProvider = connectionProvider;
            _dataTableName = dataTableName;
            _indexTableName = indexTableName;
        }
Exemple #10
0
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE posts ADD COLUMN thumb text NULL;");
     });
 }
        public HomeModule(IDbConnectionProvider connectionProvider)
        {
            Get["/"] = _ =>
            {
                using (var conn = connectionProvider.GetConnection())
                {
                    return(conn.Query <User>("select * from users"));
                }
            };

            Get["/complicatedquery"] = _ =>
            {
                //What if we need to build up a big view model and need to execute a couple of queries?
                //We could create some methods in this class and separate those queries out and build the view model up.
                //What if we have 3-4 endpoints that need to do the same? We then have a large module class which in my
                //opinion should be anaemic and have its single responsibility be for return http specific things.

                return(200);
            };

            Post["/"] = _ =>
            {
                //So we could inject a dbconnection and return data from this module but I dont like that due to the comments above.
                //What about POST/PUT? We need somewhere to do business logic etc which I think should be a service or command layer
                return(201);
            };
        }
 public SQLSubscriptionTrackingService(IDbConnectionProvider connectionProvider, ISQLDialect dialect)
 {
     if (connectionProvider == null) throw new ArgumentNullException("connectionProvider");
     if (dialect == null) throw new ArgumentNullException("dialect");
     _connectionProvider = connectionProvider;
     _dialect = dialect;
 }
 public DbProvider(string databaseName, SqliteSettings settings)
 {
     DatabaseName        = databaseName;
     _enforceForeignKeys = settings.EnforceForeignKeys;
     _sqliteDatabasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), databaseName);
     _connectionProvider = new DbConnectionProvider(_sqliteDatabasePath, settings);
 }
 /// <summary>
 /// Constructs the storage using the specified connection provider and table to store its subscriptions. If the subscription
 /// storage is shared by all subscribers and publishers, the <paramref name="isCentralized"/> parameter can be set to true
 /// in order to subscribe/unsubscribe directly instead of sending subscription/unsubscription requests
 /// </summary>
 public SqlServerSubscriptionStorage(IDbConnectionProvider connectionProvider, string tableName, bool isCentralized, IRebusLoggerFactory rebusLoggerFactory)
 {
     IsCentralized = isCentralized;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
     _connectionProvider = connectionProvider;
     _tableName = tableName;
 }
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE posts ADD COLUMN number_of_comments integer NOT NULL DEFAULT 0;");
     });
 }
Exemple #16
0
 public CaseService(IDbConnectionProvider connectionProvider, IEventBus eventBus
                    , ISmtpProvider smtpProvider)
     : base(connectionProvider)
 {
     _eventBus     = eventBus;
     _smtpProvider = smtpProvider;
 }
 public SQLSubscriptionTrackingService(ConnectionStringSettings connectionStringSettings,
     ISQLDialect dialect = null)
 {
     if (connectionStringSettings == null) throw new ArgumentNullException("connectionStringSettings");
     _connectionProvider = new DefaultConnectionProvider(connectionStringSettings);
     _dialect = dialect ?? connectionStringSettings.GetSQLDialect();
 }
Exemple #18
0
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE posts ADD COLUMN sticky boolean NOT NULL DEFAULT false;");
     });
 }
Exemple #19
0
        public override void Execute(IDbConnectionProvider conn)
        {
            conn.Perform(x =>
            {
                x.Execute("ALTER TABLE posts ADD COLUMN number_of_reports integer NOT NULL DEFAULT 0;");
                x.Execute("ALTER TABLE comments ADD COLUMN number_of_reports integer NOT NULL DEFAULT 0;");

                x.Execute("ALTER TABLE posts ADD COLUMN ignore_reports boolean NOT NULL DEFAULT false;");
                x.Execute("ALTER TABLE comments ADD COLUMN ignore_reports boolean NOT NULL DEFAULT false;");

                x.Execute(@"
            CREATE TABLE reported_comments
            (
              id uuid NOT NULL,
              created_date timestamp with time zone NOT NULL,
              reported_by uuid NOT NULL,
              reason text,
              comment uuid,
              CONSTRAINT reported_comments_pkey PRIMARY KEY (id)
            );");

                x.Execute(@"
            CREATE TABLE reported_posts
            (
              id uuid NOT NULL,
              created_date timestamp with time zone NOT NULL,
              reported_by uuid NOT NULL,
              reason text,
              post uuid,
              CONSTRAINT reported_posts_pkey PRIMARY KEY (id)
            );");
            });
        }
        public override void Execute(IDbConnectionProvider conn)
        {
            conn.Perform(x =>
            {
                x.Execute(@"
            CREATE TABLE messages
            (
              id uuid NOT NULL,
              date_created timestamp with time zone NOT NULL,
              type integer,
              parent_id uuid,
              first_message uuid,
              deleted boolean,
              author_id uuid NOT NULL,
              author_ip text,
              is_new boolean,
              to_user uuid,
              to_sub uuid,
              from_sub uuid,
              subject text,
              body text,
              body_formatted text,
              CONSTRAINT messages_pkey PRIMARY KEY (id)
            );");

                x.Execute(@"
            CREATE INDEX messages_datecreated_index ON messages(date_created);
            ");

            });
        }
Exemple #21
0
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="connectionProvider">A <see cref="IDbConnection"/> to obtain a database connection</param>
    /// <param name="inputQueueName">Name of the queue this transport is servicing</param>
    /// <param name="rebusLoggerFactory">A <seealso cref="IRebusLoggerFactory"/> for building loggers</param>
    /// <param name="asyncTaskFactory">A <seealso cref="IAsyncTaskFactory"/> for creating periodic tasks</param>
    /// <param name="rebusTime">A <seealso cref="IRebusTime"/> to provide the current time</param>
    /// <param name="leaseInterval">Interval of time messages are leased for</param>
    /// <param name="leaseTolerance">Buffer to allow lease overruns by</param>
    /// <param name="leasedByFactory">Factory for generating a string which identifies who has leased a message (eg. A hostname)</param>
    /// <param name="options">Additional options</param>
    public SqlServerLeaseTransport(
        IDbConnectionProvider connectionProvider,
        string inputQueueName,
        IRebusLoggerFactory rebusLoggerFactory,
        IAsyncTaskFactory asyncTaskFactory,
        IRebusTime rebusTime,
        TimeSpan leaseInterval,
        TimeSpan?leaseTolerance,
        Func <string> leasedByFactory,
        SqlServerLeaseTransportOptions options
        ) : base(connectionProvider, inputQueueName, rebusLoggerFactory, asyncTaskFactory, rebusTime, options)
    {
        _leasedByFactory = leasedByFactory;
        _leaseInterval   = leaseInterval;
        _leaseTolerance  = leaseTolerance ?? TimeSpan.FromSeconds(15);

        var automaticLeaseRenewalInterval = options.LeaseAutoRenewInterval;

        if (!automaticLeaseRenewalInterval.HasValue)
        {
            _automaticLeaseRenewal = false;
        }
        else
        {
            _automaticLeaseRenewal         = true;
            _automaticLeaseRenewalInterval = automaticLeaseRenewalInterval.Value;
        }
    }
        /// <summary>
        /// Constructs the storage using the specified connection provider and table to store its subscriptions. If the subscription
        /// storage is shared by all subscribers and publishers, the <paramref name="isCentralized"/> parameter can be set to true
        /// in order to subscribe/unsubscribe directly instead of sending subscription/unsubscription requests
        /// </summary>
        public SqlServerSubscriptionStorage(IDbConnectionProvider connectionProvider, string tableName, bool isCentralized)
        {

            IsCentralized = isCentralized;
            _connectionProvider = connectionProvider;
            _tableName = tableName;
        }
 public PeriodicInspectionService(IDbConnectionProvider connectionProvider, IEventBus eventBus,
                                  ISettingsService settingsService)
     : base(connectionProvider)
 {
     _eventBus        = eventBus;
     _settingsService = settingsService;
 }
Exemple #24
0
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE posts ADD COLUMN thumb text NULL;");
     });
 }
Exemple #25
0
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE posts ADD COLUMN deleted boolean NOT NULL default false;");
     });
 }
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE users ADD COLUMN is_admin boolean NOT NULL default false;");
     });
 }
Exemple #27
0
        public override void Execute(IDbConnectionProvider conn)
        {
            conn.Perform(x =>
            {
                x.Execute("ALTER TABLE posts ADD COLUMN number_of_reports integer NOT NULL DEFAULT 0;");
                x.Execute("ALTER TABLE comments ADD COLUMN number_of_reports integer NOT NULL DEFAULT 0;");

                x.Execute("ALTER TABLE posts ADD COLUMN ignore_reports boolean NOT NULL DEFAULT false;");
                x.Execute("ALTER TABLE comments ADD COLUMN ignore_reports boolean NOT NULL DEFAULT false;");

                x.Execute(@"
CREATE TABLE reported_comments
(
  id uuid NOT NULL,
  created_date timestamp with time zone NOT NULL,
  reported_by uuid NOT NULL,
  reason text,
  comment uuid,
  CONSTRAINT reported_comments_pkey PRIMARY KEY (id)
);");

                x.Execute(@"
CREATE TABLE reported_posts
(
  id uuid NOT NULL,
  created_date timestamp with time zone NOT NULL,
  reported_by uuid NOT NULL,
  reason text,
  post uuid,
  CONSTRAINT reported_posts_pkey PRIMARY KEY (id)
);");
            });
        }
Exemple #28
0
 public CommentDao(IDbConnectionProvider conn,
                   ICommentTreeBuilder commentTreeBuilder)
     : base(conn)
 {
     _conn = conn;
     _commentTreeBuilder = commentTreeBuilder;
 }
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE subs ADD COLUMN created_by uuid NULL;");
     });
 }
Exemple #30
0
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         CreateFunctions(x);
         CreateTables(x);
     });
 }
Exemple #31
0
 public QueryResultContext(ISqlExcuter excutor, DbDataReader reader, DbConnection connection, IDbConnectionProvider provider)
 {
     Reader             = reader;
     ResultTable        = QueryResultTableMetaData.Create(reader);
     ConnectionProvider = provider;
     Connection         = connection;
     Excutor            = excutor;
 }
Exemple #32
0
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE messages ADD COLUMN post uuid NULL;");
         x.Execute("ALTER TABLE messages ADD COLUMN comment uuid NULL;");
     });
 }
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE messages ADD COLUMN post uuid NULL;");
         x.Execute("ALTER TABLE messages ADD COLUMN comment uuid NULL;");
     });
 }
Exemple #34
0
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE subs ADD COLUMN in_all boolean NOT NULL default TRUE;");
         x.Execute("ALTER TABLE posts ADD COLUMN in_all boolean NOT NULL default TRUE;");
     });
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PaymentTermRepository" /> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 public PaymentTermRepository(IDbConnectionProvider provider)
 {
     this._provider = provider;
     if (this._provider == null)
     {
         throw new ArgumentNullException("PaymentTermRepository.IDbConnectionProvider");
     }
 }
 /// <summary>
 /// Initializes a new <see cref="SQLMessageJournal"/> with the specified connection
 /// provider and dialect
 /// </summary>
 /// <param name="connectionProvider">The connection provider to use to connect to
 ///     the SQL database</param>
 /// <param name="commandBuilders">A set of commands that conform to the SQL syntax
 ///     required by the underlying connection provider</param>
 /// <param name="diagnosticService">(Optional) The service through which diagnostic events
 ///     are reported and processed</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="connectionProvider"/>
 /// or <paramref name="commandBuilders"/> is <c>null</c></exception>
 public SQLMessageJournal(IDbConnectionProvider connectionProvider,
                          IMessageJournalingCommandBuilders commandBuilders,
                          IDiagnosticService diagnosticService = null)
 {
     DiagnosticService  = diagnosticService ?? Diagnostics.DiagnosticService.DefaultInstance;
     ConnectionProvider = connectionProvider ?? throw new ArgumentNullException(nameof(connectionProvider));
     CommandBuilders    = commandBuilders ?? throw new ArgumentNullException(nameof(commandBuilders));
 }
Exemple #37
0
        public Versioner(IDbConnectionProvider connectionProvider, ILogger<Version> logger)
        {
            _conn = connectionProvider;
            _logger = logger;

            _logger.Debug("Create mapper and table instances");
            _conn.Perform(conn => conn.CreateTableIfNotExists<DatabaseVersion>());
        }
Exemple #38
0
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE posts ADD COLUMN nsfw boolean NOT NULL default false;");
         x.Execute("ALTER TABLE subs ADD COLUMN nsfw boolean NOT NULL default false;");
     });
 }
Exemple #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CurrencyRepository" /> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 public CurrencyRepository(IDbConnectionProvider provider)
 {
     this._provider = provider;
     if (this._provider == null)
     {
         throw new ArgumentNullException("CurrencyRepository.IDbConnectionProvider");
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EmailServerRepository" /> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 public EmailServerRepository(IDbConnectionProvider provider)
 {
     this._provider = provider;
     if (this._provider == null)
     {
         throw new ArgumentNullException("EmailServerRepository.IDbConnectionProvider");
     }
 }
Exemple #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlDbPingHealthCheckStrategy"/> class.
 /// </summary>
 /// <param name="dbConnectionProvider">The database connection provider.</param>
 /// <exception cref="ArgumentNullException"></exception>
 /// <seealso cref="IDbConnectionProvider" />
 public SqlDbPingHealthCheckStrategy(IDbConnectionProvider dbConnectionProvider)
 {
     if (dbConnectionProvider == null)
     {
         throw new ArgumentNullException(nameof(dbConnectionProvider));
     }
     _dbConnectionProvider = dbConnectionProvider;
 }
Exemple #42
0
 /// <summary>
 /// Initializes a new <see cref="SQLSubscriptionTrackingService"/> with the specified connection
 /// provider and dialect
 /// </summary>
 /// <param name="connectionProvider">The connection provider to use to connect to
 ///     the SQL database</param>
 /// <param name="commandBuilders">A collection of factories capable of
 ///     generating database commands for manipulating subscriptions that conform to the SQL
 ///     syntax required by the underlying connection provider</param>
 /// <param name="diagnosticService">(Optional) The service through which diagnostic events
 ///     are reported and processed</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="connectionProvider"/>
 /// or <paramref name="commandBuilders"/> is <c>null</c></exception>
 public SQLSubscriptionTrackingService(IDbConnectionProvider connectionProvider,
                                       ISubscriptionTrackingCommandBuilders commandBuilders,
                                       IDiagnosticService diagnosticService = null)
 {
     DiagnosticService  = diagnosticService ?? Diagnostics.DiagnosticService.DefaultInstance;
     ConnectionProvider = connectionProvider ?? throw new ArgumentNullException(nameof(connectionProvider));
     _commandBuilders   = commandBuilders ?? throw new ArgumentNullException(nameof(commandBuilders));
 }
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         CreateFunctions(x);
         CreateTables(x);
     });
 }
Exemple #44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActivityLogRepository" /> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 public ActivityLogRepository(IDbConnectionProvider provider)
 {
     this._provider = provider;
     if (this._provider == null)
     {
         throw new ArgumentNullException("ActivityLogRepository.IDbConnectionProvider");
     }
 }
        /// <summary>
        /// Creates the options with the given <paramref name="connectionProvider"/>
        /// </summary>
        public SqlServerSagaSnapshotStorageOptions(IDbConnectionProvider connectionProvider)
        {
            if (connectionProvider == null)
            {
                throw new ArgumentNullException(nameof(connectionProvider));
            }

            ConnectionProviderFactory = context => connectionProvider;
        }
Exemple #46
0
    /// <summary>
    /// Creates the options with the given <paramref name="connectionProvider"/>
    /// </summary>
    public SqlServerTimeoutManagerOptions(IDbConnectionProvider connectionProvider)
    {
        if (connectionProvider == null)
        {
            throw new ArgumentNullException(nameof(connectionProvider));
        }

        ConnectionProviderFactory = context => connectionProvider;
    }
Exemple #47
0
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE sub_admins RENAME TO moderators");
         // "1" is "All" permission
         x.Execute("ALTER TABLE moderators ADD COLUMN permissions integer DEFAULT 1");
     });
 }
Exemple #48
0
        public IdentityService(IDbConnectionProvider connectionProvider, ICacheProvider cacheProvider,
                               ISmtpProvider smtpProvider, IEventBus eventBus)
            : base(connectionProvider)
        {
            _cacheProvider = cacheProvider;
            _smtpProvider  = smtpProvider;

            _eventBus = eventBus;
        }
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE subs ADD COLUMN sidebar_text_formatted text NULL;");
         x.Execute("ALTER TABLE subs ADD COLUMN submission_text text NULL;");
         x.Execute("ALTER TABLE subs ADD COLUMN submission_text_formatted text NULL;");
     });
 }
Exemple #50
0
        public SqlDbContextObjectsProvider(IDbConnectionProvider dbConnectionProvider)
        {
            if (dbConnectionProvider == null)
            {
                throw new ArgumentNullException(nameof(dbConnectionProvider));
            }

            _dbConnectionProvider = dbConnectionProvider;
        }
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE sub_admins RENAME TO moderators");
         // "1" is "All" permission
         x.Execute("ALTER TABLE moderators ADD COLUMN permissions integer DEFAULT 1");
     });
 }
 public override void Execute(IDbConnectionProvider conn)
 {
     conn.Perform(x =>
     {
         x.Execute("ALTER TABLE posts ADD COLUMN verdict integer NOT NULL DEFAULT 0;");
         x.Execute("ALTER TABLE posts ADD COLUMN approved_by uuid NULL;");
         x.Execute("ALTER TABLE posts ADD COLUMN removed_by uuid NULL;");
         x.Execute("ALTER TABLE posts ADD COLUMN verdict_message text NULL;");
     });
 }
 /// <summary>
 /// Creates the data storage
 /// </summary>
 public SqlServerDataBusStorage(IDbConnectionProvider connectionProvider, string tableName, bool ensureTableIsCreated, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (connectionProvider == null) throw new ArgumentNullException(nameof(connectionProvider));
     if (tableName == null) throw new ArgumentNullException(nameof(tableName));
     if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
     _connectionProvider = connectionProvider;
     _tableName = tableName;
     _ensureTableIsCreated = ensureTableIsCreated;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
 public TrackableSetValueTest(IDbConnectionProvider dbConnectionProvider, ISqlProvider sqlProvider)
     : base(useDuplicateCheck: true)
 {
     _db = dbConnectionProvider;
     _mapper = new TrackableSetSqlMapper<int>(
         sqlProvider,
         nameof(TrackableSetValueTest),
         new ColumnDefinition("Value", typeof(int)),
         null);
     _mapper.ResetTableAsync(_db.Connection).Wait();
 }
Exemple #55
0
        /// <summary>
        /// Constructs the transport with the given <see cref="IDbConnectionProvider"/>, using the specified <paramref name="tableName"/> to send/receive messages,
        /// querying for messages with recipient = <paramref name="inputQueueName"/>
        /// </summary>
        public SqlServerTransport(IDbConnectionProvider connectionProvider, string tableName, string inputQueueName, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory)
        {
            _connectionProvider = connectionProvider;
            _tableName = tableName;
            _inputQueueName = inputQueueName;
            _log = rebusLoggerFactory.GetCurrentClassLogger();

            ExpiredMessagesCleanupInterval = DefaultExpiredMessagesCleanupInterval;

            _expiredMessagesCleanupTask = asyncTaskFactory.Create("ExpiredMessagesCleanup", PerformExpiredMessagesCleanupCycle, intervalSeconds: 60);
        }
        public bool Execute(IDbConnectionProvider conn, MigrationResources resources)
        {
            _logger.Debug("Initialize database versioner");
            var versioner = new Versioner(conn, new Logger<Version>());

            _logger.Debug("Initialize executor");
            var executor = new Executor(conn, versioner, new Logger<Executor>());

            _logger.Debug("Execute migrations");
            return executor.Execute(resources);
        }
        /// <summary>
        /// Constructs the saga storage, using the specified connection provider and tables for persistence.
        /// </summary>
		public SqlServerSagaStorage(IDbConnectionProvider connectionProvider, string dataTableName, string indexTableName, IRebusLoggerFactory rebusLoggerFactory)
        {
            if (connectionProvider == null) throw new ArgumentNullException(nameof(connectionProvider));
            if (dataTableName == null) throw new ArgumentNullException(nameof(dataTableName));
            if (indexTableName == null) throw new ArgumentNullException(nameof(indexTableName));
            if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
            _log = rebusLoggerFactory.GetCurrentClassLogger();
            _connectionProvider = connectionProvider;
            _dataTableName = dataTableName;
            _indexTableName = indexTableName;
        }
Exemple #58
0
        /// <summary>
        /// Constructs the transport with the given <see cref="IDbConnectionProvider"/>, using the specified <paramref name="tableName"/> to send/receive messages,
        /// querying for messages with recipient = <paramref name="inputQueueName"/>
        /// </summary>
        public SqlServerTransport(IDbConnectionProvider connectionProvider, string tableName, string inputQueueName)
        {
            _connectionProvider = connectionProvider;
            _tableName = tableName;
            _inputQueueName = inputQueueName;

            ExpiredMessagesCleanupInterval = DefaultExpiredMessagesCleanupInterval;

            _expiredMessagesCleanupTask = new AsyncTask("ExpiredMessagesCleanup", PerformExpiredMessagesCleanupCycle)
            {
                Interval = TimeSpan.FromMinutes(1)
            };
        }
        /// <summary>
        /// Constructs the transport with the given <see cref="IDbConnectionProvider"/>, using the specified <paramref name="tableName"/> to send/receive messages,
        /// querying for messages with recipient = <paramref name="inputQueueName"/>
        /// </summary>
        public SqlServerTransport(IDbConnectionProvider connectionProvider, string tableName, string inputQueueName, IRebusLoggerFactory rebusLoggerFactory)
        {
            _connectionProvider = connectionProvider;
            _tableName = tableName;
            _inputQueueName = inputQueueName;
            _log = rebusLoggerFactory.GetCurrentClassLogger();

            ExpiredMessagesCleanupInterval = DefaultExpiredMessagesCleanupInterval;

            _expiredMessagesCleanupTask = new AsyncTask("ExpiredMessagesCleanup", PerformExpiredMessagesCleanupCycle, rebusLoggerFactory)
            {
                Interval = TimeSpan.FromMinutes(1)
            };
        }
Exemple #60
0
        protected override void Setup()
        {
            base.Setup();

            Cassandra.Migrations.Migrations.Run(_serviceProvider);
            Postgres.Migrations.Migrations.Run(_serviceProvider);

            _conn = _serviceProvider.GetService<IDbConnectionProvider>();
            _conn.Perform(conn =>
            {
                conn.ExecuteProcedure(new ClearDatabaseFunction());
                conn.ExecuteProcedure(new EnsureDefaultUserFunction());
            });
        }