public static string Create(IConnectionInformation connectionInfo)
            {
                using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Soe.Common.App.config"))
                {
                    if (stream == Stream.Null)
                    {
                        throw new ArgumentNullException("stream");
                    }

                    var xdoc = new XmlDocument();
                    xdoc.Load(stream);

                    var xnodes = xdoc.SelectSingleNode("/configuration/appSettings");
                    foreach (XmlNode node in xnodes.ChildNodes)
                    {
                        if (node.Attributes["key"].Value == "sgid_instance")
                        {
                            _instance = node.Attributes["value"].Value;
                        }
                    }
                }

                return string.Format("Data Source={3};Initial Catalog={0};Persist Security Info=True;User ID={1};Password={2}", 
                                     connectionInfo.DatabaseName,connectionInfo.Name,connectionInfo.Password, _instance);
            }
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueStatusProviderNoOp" /> class.
 /// </summary>
 /// <param name="connectionInformation">The connection information.</param>
 public QueueStatusProviderNoOp(IConnectionInformation connectionInformation)
 {
     Name = connectionInformation.QueueName;
     Server = connectionInformation.Server;
     _queueInformation = new QueueInformation(Name, Server, DateTime.MinValue, string.Empty,
         Enumerable.Empty<SystemEntry>());
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SendHeartBeatDecorator" /> class.
 /// </summary>
 /// <param name="metrics">The metrics factory.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="connectionInformation">The connection information.</param>
 public SendHeartBeatDecorator(IMetrics metrics,
     ISendHeartBeat handler,
     IConnectionInformation connectionInformation)
 {
     var name = handler.GetType().Name;
     _timer = metrics.Timer($"{connectionInformation.QueueName}.{name}.SendTimer", Units.Calls);
     _handler = handler;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueCreationDecorator" /> class.
 /// </summary>
 /// <param name="metrics">The metrics factory.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="connectionInformation">The connection information.</param>
 public MessageHandlerDecorator(IMetrics metrics,
     IMessageHandler handler,
     IConnectionInformation connectionInformation)
 {
     var name = handler.GetType().Name;
     _runCodeTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.HandleTimer", Units.Calls);
     _handler = handler;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ReceivePoisonMessageDecorator" /> class.
 /// </summary>
 /// <param name="metrics">The metrics factory.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="connectionInformation">The connection information.</param>
 public ReceivePoisonMessageDecorator(IMetrics metrics,
     IReceivePoisonMessage handler,
     IConnectionInformation connectionInformation)
 {
     var name = handler.GetType().Name;
     _meterError = metrics.Meter($"{connectionInformation.QueueName}.{name}.PoisonHandleMeter", Units.Items);
     _handler = handler;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueStatusProviderBase" /> class.
 /// </summary>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 protected QueueStatusProviderBase(IConnectionInformation connectionInformation,
     IGetTimeFactory getTimeFactory)
 {
     TimeFactory = getTimeFactory;
     ConnectionInformation = connectionInformation;
     Name = connectionInformation.QueueName;
     Server = connectionInformation.Server;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RollbackMessageDecorator" /> class.
 /// </summary>
 /// <param name="metrics">The metrics factory.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="connectionInformation">The connection information.</param>
 public RollbackMessageDecorator(IMetrics metrics,
     IRollbackMessage handler,
     IConnectionInformation connectionInformation)
 {
     var name = handler.GetType().Name;
     _rollbackCounter = metrics.Counter($"{connectionInformation.QueueName}.{name}.RollbackCounter", Units.Items);
     _handler = handler;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueCreationDecorator" /> class.
 /// </summary>
 /// <param name="metrics">The metrics factory.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="connectionInformation">The connection information.</param>
 public QueueCreationDecorator(IMetrics metrics,
     IQueueCreation handler,
     IConnectionInformation connectionInformation)
 {
     var name = handler.GetType().Name;
     _createQueueTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.CreateQueueTimer", Units.Calls);
     _removeQueueTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.RemoveQueueTimer", Units.Calls);
     _handler = handler;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ReceiveMessagesErrorDecorator" /> class.
 /// </summary>
 /// <param name="metrics">The metrics factory.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="connectionInformation">The connection information.</param>
 public ReceiveMessagesErrorDecorator(IMetrics metrics,
     IReceiveMessagesError handler,
     IConnectionInformation connectionInformation)
 {
     var name = handler.GetType().Name;
     _meterError = metrics.Meter($"{connectionInformation.QueueName}.{name}.MessageFailedProcessingErrorMeter", Units.Items);
     _meterRetry = metrics.Meter($"{connectionInformation.QueueName}.{name}.MessageFailedProcessingRetryMeter", Units.Items);
     _handler = handler;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SqLiteMessageQueueTransportOptionsFactory"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="queryOptions">The query options.</param>
        public SqLiteMessageQueueTransportOptionsFactory(IConnectionInformation connectionInformation,
            IQueryHandler<GetQueueOptionsQuery, SqLiteMessageQueueTransportOptions> queryOptions)
        {
            Guard.NotNull(() => queryOptions, queryOptions);
            Guard.NotNull(() => connectionInformation, connectionInformation);

            _queryOptions = queryOptions;
            _connectionInformation = connectionInformation;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ConnectionFactory" /> class.
        /// </summary>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="options">The options.</param>
        public ConnectionFactory(IConnectionInformation connectionInfo,
            ISqlServerMessageQueueTransportOptionsFactory options)
        {
            Guard.NotNull(() => connectionInfo, connectionInfo);
            Guard.NotNull(() => options, options);

            _connectionInfo = connectionInfo;
            _options = new Lazy<SqlServerMessageQueueTransportOptions>(options.Create);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="InternalSerializerDecorator" /> class.
 /// </summary>
 /// <param name="metrics">The metrics factory.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="connectionInformation">The connection information.</param>
 public LinqCompilerDecorator(IMetrics metrics,
     ILinqCompiler handler,
     IConnectionInformation connectionInformation)
 {
     var name = handler.GetType().Name;
     _compileActionTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.CompileActionTimer", Units.Calls);
     _compileFunctionTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.CompileFunctionTimer", Units.Calls);
     _handler = handler;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PostgreSqlQueueStatusProvider" /> class.
 /// </summary>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 /// <param name="optionsFactory">The options factory.</param>
 /// <param name="serializer">The serializer.</param>
 /// <param name="queries">The queries.</param>
 public PostgreSqlQueueStatusProvider(IConnectionInformation connectionInformation,
     IGetTimeFactory getTimeFactory,
     IPostgreSqlMessageQueueTransportOptionsFactory optionsFactory,
     IInternalSerializer serializer, 
     PostgreSqlMessageQueueStatusQueries queries) : base(connectionInformation, getTimeFactory)
 {
     _serializer = serializer;
     _queries = queries;
     _options = new Lazy<PostgreSqlMessageQueueTransportOptions>(optionsFactory.Create);
 }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlServerTime" /> class.
 /// </summary>
 /// <param name="log">The log.</param>
 /// <param name="configuration">The configuration.</param>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="dateTimeQueryHandler">The date time query handler.</param>
 public SqlServerTime(ILogFactory log,
     BaseTimeConfiguration configuration,
     IConnectionInformation connectionInformation,
     IQueryHandler<GetUtcDateQuery, DateTime> dateTimeQueryHandler) : base(log, configuration)
 {
     Guard.NotNull(() => connectionInformation, connectionInformation);
     Guard.NotNull(() => dateTimeQueryHandler, dateTimeQueryHandler);
     _queryHandler = dateTimeQueryHandler;
     _connectionInformation = connectionInformation;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageMethodHandlingDecorator" /> class.
 /// </summary>
 /// <param name="metrics">The metrics factory.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="connectionInformation">The connection information.</param>
 public MessageMethodHandlingDecorator(IMetrics metrics,
     IMessageMethodHandling handler,
     IConnectionInformation connectionInformation)
 {
     var name = handler.GetType().Name;
     _runMethodCompiledCodeTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.HandleCompiledMethodTimer", Units.Calls);
     _runFunctionCompiledCodeTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.HandleCompiledFunctionTimer", Units.Calls);
     _runMethodDynamicCodeTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.HandleDynamicMethodTimer", Units.Calls);
     _runFunctionDynamicCodeTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.HandleDynamicFunctionTimer", Units.Calls);
     _handler = handler;
 }
Example #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Connection" /> class.
        /// </summary>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="options">The options.</param>
        public Connection(IConnectionInformation connectionInfo,
            SqlServerMessageQueueTransportOptions options)
        {
            SqlConnection = new SqlConnection(connectionInfo.ConnectionString);
            SqlConnection.Open();

            if (options.EnableHoldTransactionUntilMessageCommited)
            {
                SqlTransaction = SqlConnection.BeginTransaction(IsolationLevel.ReadCommitted);
            }
        }
Example #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Connection" /> class.
        /// </summary>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="options">The options.</param>
        public Connection(IConnectionInformation connectionInfo,
            PostgreSqlMessageQueueTransportOptions options)
        {
            NpgsqlConnection = new NpgsqlConnection(connectionInfo.ConnectionString);
            NpgsqlConnection.Open();

            if (options.EnableHoldTransactionUntilMessageCommited)
            {
                NpgsqlTransaction = NpgsqlConnection.BeginTransaction(IsolationLevel.ReadCommitted);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlMessageQueueClearExpiredMessages" /> class.
        /// </summary>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="findExpiredMessagesQueryHandler">The find expired messages query handler.</param>
        /// <param name="deleteMessageCommandHandler">The delete message command handler.</param>
        public PostgreSqlMessageQueueClearExpiredMessages(IConnectionInformation connectionInfo,
            IQueryHandler<FindExpiredMessagesToDeleteQuery, IEnumerable<long>> findExpiredMessagesQueryHandler, 
            ICommandHandlerWithOutput<DeleteMessageCommand, long> deleteMessageCommandHandler)
        {
            Guard.NotNull(() => connectionInfo, connectionInfo);
            Guard.NotNull(() => findExpiredMessagesQueryHandler, findExpiredMessagesQueryHandler);
            Guard.NotNull(() => deleteMessageCommandHandler, deleteMessageCommandHandler);

            _connectionInfo = connectionInfo;
            _findExpiredMessagesQueryHandler = findExpiredMessagesQueryHandler;
            _deleteMessageCommandHandler = deleteMessageCommandHandler;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ClearExpiredMessagesDecorator" /> class.
        /// </summary>
        /// <param name="log">The log.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInfo">The connection information.</param>
        public ClearExpiredMessagesDecorator(ILogFactory log,
            IClearExpiredMessages handler, 
            IConnectionInformation connectionInfo)
        {
            Guard.NotNull(() => log, log);
            Guard.NotNull(() => handler, handler);
            Guard.NotNull(() => connectionInfo, connectionInfo);

            _log = log.Create();
            _handler = handler;
            _connectionInfo = connectionInfo;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DelayedProcessingActionDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public DelayedProcessingActionDecorator(IMetrics metrics,
            IDelayedProcessingAction handler,
            IConnectionInformation connectionInformation)
        {
            Guard.NotNull(() => metrics, metrics);
            Guard.NotNull(() => handler, handler);

            var name = handler.GetType().Name;
            _timer = metrics.Timer($"{connectionInformation.QueueName}.{name}.RunTimer", Units.Calls);
            _counter = metrics.Counter($"{connectionInformation.QueueName}.{name}.RunCounter", Units.Items);
            _handler = handler;
        }
Example #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExpressionSerializerDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public ExpressionSerializerDecorator(IMetrics metrics,
                                             IExpressionSerializer handler,
                                             IConnectionInformation connectionInformation)
        {
            var name = "ExpressionSerializer";

            _methodToBytesTimer        = metrics.Timer($"{connectionInformation.QueueName}.{name}.ConvertMethodToBytesTimer", Units.Calls);
            _bytesToMethodTimer        = metrics.Timer($"{connectionInformation.QueueName}.{name}.ConvertBytesToMethodTimer", Units.Calls);
            _resultMethodSizeHistogram = metrics.Histogram($"{connectionInformation.QueueName}.{name}.ConvertMethodToBytesHistogram", Units.Bytes,
                                                           SamplingTypes.LongTerm);

            _handler = handler;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializerDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public SerializerDecorator(IMetrics metrics,
                                   ISerializer handler,
                                   IConnectionInformation connectionInformation)
        {
            var name = "Serializer";

            DisplayName          = handler.DisplayName;
            _bytesToMessageTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.ConvertBytesToMessageTimer", Units.Calls);
            _messageToBytesTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.ConvertMessageToBytesTimer", Units.Calls);
            _resultSizeHistogram = metrics.Histogram($"{connectionInformation.QueueName}.{name}.ConvertMessageToBytesHistogram", Units.Bytes,
                                                     SamplingTypes.LongTerm);
            _handler = handler;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ReceiveMessagesDecorator" /> class.
 /// </summary>
 /// <param name="metrics">The metrics factory.</param>
 /// <param name="headers">The headers.</param>
 /// <param name="getTime">The get time.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="connectionInformation">The connection information.</param>
 public ReceiveMessagesDecorator(IMetrics metrics,
     IHeaders headers,
     IGetTimeFactory getTime,
     IReceiveMessages handler,
     IConnectionInformation connectionInformation)
 {
     var name = handler.GetType().Name;
     _meter = metrics.Meter($"{connectionInformation.QueueName}.{name}.ReceiveMessageMeter", Units.Items);
     _waitTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.WaitForDeQueueMeter", Units.None);
     _handler = handler;
     _getTime = getTime;
     _headers = headers;
 }
Example #24
0
        /*
         * SELECT c.name TABLE_SCHEMA,
         * b.name TABLE_NAME,
         * a.name COLUMN_NAME,
         * IDENT_SEED(c.name + '.' + b.name) IDENTITY_SEED,
         * IDENT_INCR(c.name + '.' + b.name) IDENTITY_INCREMENT
         * FROM   sys.columns a
         * INNER JOIN sys.tables b ON b.object_id = a.object_id
         * INNER JOIN sys.schemas c ON c.schema_id = b.schema_id
         * WHERE  a.is_identity = 1;
         */
        public override DbObjectCollection CreateCollection(IConnectionInformation info)
        {
            var collection = new DbObjectCollection(info);
            var con        = collection.Initialization();
            var table      = con.GetSchema("Tables");

            collection.RegisterObjects(table, true, "TABLE_TYPE = 'BASE TABLE'");
            collection.RegisterObjects(table, false, "TABLE_TYPE = 'VIEW'");
            collection.RegisterMembers(con.GetSchema("Columns"), new DbObjectCollection.ColumnCreator());

            collection.RegisterPrimaryKey();
            return(collection);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DelayedProcessingActionDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public DelayedProcessingActionDecorator(IMetrics metrics,
                                                IDelayedProcessingAction handler,
                                                IConnectionInformation connectionInformation)
        {
            Guard.NotNull(() => metrics, metrics);
            Guard.NotNull(() => handler, handler);

            var name = handler.GetType().Name;

            _timer   = metrics.Timer($"{connectionInformation.QueueName}.{name}.RunTimer", Units.Calls);
            _counter = metrics.Counter($"{connectionInformation.QueueName}.{name}.RunCounter", Units.Items);
            _handler = handler;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TransportConfigurationReceive" /> class.
        /// </summary>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="queueDelayFactory">The queue delay factory.</param>
        /// <param name="retryDelayFactory">The retry delay factory.</param>
        public TransportConfigurationReceive(IConnectionInformation connectionInfo, 
            IQueueDelayFactory queueDelayFactory, 
            IRetryDelayFactory retryDelayFactory)
        {
            Guard.NotNull(() => connectionInfo, connectionInfo);
            Guard.NotNull(() => queueDelayFactory, queueDelayFactory);
            Guard.NotNull(() => retryDelayFactory, retryDelayFactory);
            ConnectionInfo = connectionInfo;

            QueueDelayBehavior = queueDelayFactory.Create(new List<TimeSpan>());
            RetryDelayBehavior = retryDelayFactory.Create();
            FatalExceptionDelayBehavior = queueDelayFactory.Create(new List<TimeSpan>());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RollbackMessageCommandHandler" /> class.
 /// </summary>
 /// <param name="getUtcDateQuery">The get UTC date query.</param>
 /// <param name="options">The options.</param>
 /// <param name="tableNameHelper">The table name helper.</param>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="commandCache">The command cache.</param>
 public RollbackMessageCommandHandler(IGetTimeFactory getUtcDateQuery,
                                      IPostgreSqlMessageQueueTransportOptionsFactory options,
                                      ITableNameHelper tableNameHelper,
                                      IConnectionInformation connectionInformation,
                                      PostgreSqlCommandStringCache commandCache)
 {
     _getUtcDateQuery       = getUtcDateQuery;
     _options               = new Lazy <PostgreSqlMessageQueueTransportOptions>(options.Create);
     _tableNameHelper       = tableNameHelper;
     _connectionInformation = connectionInformation;
     _commandCache          = commandCache;
     _rollbackDictionary    = new ConcurrentDictionary <string, string>();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SendMessagesDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public SendMessagesDecorator(IMetrics metrics,
            ISendMessages handler,
            IConnectionInformation connectionInformation)
        {
            var name = handler.GetType().Name;
            _sendTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.SendTimer", Units.Calls);
            _sendBatchTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.SendBatchTimer", Units.Calls);
            _sendAsyncTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.SendAsyncTimer", Units.Calls);
            _sendBatchAsyncTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.SendBatchAsyncTimer", Units.Calls);

            _sendMeter = metrics.Meter($"{connectionInformation.QueueName}.{name}.SendMessagesMeter", Units.Items, TimeUnits.Minutes);
            _sendErrorMeter = metrics.Meter($"{connectionInformation.QueueName}.{name}.SendMessagesErrorMeter", Units.Items, TimeUnits.Minutes);
            _handler = handler;
        }
Example #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReceiveMessagesDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="headers">The headers.</param>
        /// <param name="getTime">The get time.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public ReceiveMessagesDecorator(IMetrics metrics,
                                        IHeaders headers,
                                        IGetTimeFactory getTime,
                                        IReceiveMessages handler,
                                        IConnectionInformation connectionInformation)
        {
            var name = "ReceiveMessages";

            _meter     = metrics.Meter($"{connectionInformation.QueueName}.{name}.ReceiveMessageMeter", Units.Items);
            _waitTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.WaitForDeQueueMeter", Units.None);
            _handler   = handler;
            _getTime   = getTime;
            _headers   = headers;
        }
Example #30
0
        public override DbObjectCollection CreateCollection(IConnectionInformation info)
        {
            var collection = new DbObjectCollection(info);

            collection.Names.DataTypeKey = "NativeDataType";
            var con     = collection.Initialization();
            var table   = con.GetSchema("Tables");
            var creator = new DbObjectCollection.ColumnCreator();
            var rows    = table.AsEnumerable().Where(a => !a.Field <string>("TABLE_NAME").EndsWith("$")).ToArray();

            collection.RegisterObjects(rows, true);
            collection.RegisterMembers(con.GetSchema("Columns"), creator);
            return(collection);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SendMessagesDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public SendMessagesDecorator(IMetrics metrics,
            ISendMessages handler,
            IConnectionInformation connectionInformation)
        {
            var name = "SendMessages";
            _sendTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.SendTimer", Units.Calls);
            _sendBatchTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.SendBatchTimer", Units.Calls);
            _sendAsyncTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.SendAsyncTimer", Units.Calls);
            _sendBatchAsyncTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.SendBatchAsyncTimer", Units.Calls);

            _sendMeter = metrics.Meter($"{connectionInformation.QueueName}.{name}.SendMessagesMeter", Units.Items, TimeUnits.Minutes);
            _sendErrorMeter = metrics.Meter($"{connectionInformation.QueueName}.{name}.SendMessagesErrorMeter", Units.Items, TimeUnits.Minutes);
            _handler = handler;
        }
Example #32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InternalSerializerDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public InternalSerializerDecorator(IMetrics metrics,
                                           IInternalSerializer handler,
                                           IConnectionInformation connectionInformation)
        {
            var name = handler.GetType().Name;

            _bytesToMessageTimer  = metrics.Timer($"{connectionInformation.QueueName}.{name}.ConvertBytesToTimer", Units.Calls);
            _messageToBytesTimer  = metrics.Timer($"{connectionInformation.QueueName}.{name}.ConvertToBytesTimer", Units.Calls);
            _messageToStringTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.ConvertToStringTimer", Units.Calls);
            _resultSizeHistogram  = metrics.Histogram($"{connectionInformation.QueueName}.{name}.ConvertToBytesHistogram", Units.Bytes,
                                                      SamplingTypes.LongTerm);
            _resultSizeStringHistogram = metrics.Histogram($"{connectionInformation.QueueName}.{name}.ConvertToStringHistogram", Units.Bytes,
                                                           SamplingTypes.LongTerm);
            _handler = handler;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisQueueCreation" /> class.
        /// </summary>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="redisConnection">The redis connection.</param>
        /// <param name="redisNames">The redis names.</param>
        /// <param name="creationScope">The creation scope.</param>
        public RedisQueueCreation(IConnectionInformation connectionInfo,
            IRedisConnection redisConnection,
            RedisNames redisNames,
            ICreationScope creationScope)
        {
            Guard.NotNull(() => connectionInfo, connectionInfo);
            Guard.NotNull(() => redisConnection, redisConnection);
            Guard.NotNull(() => redisNames, redisNames);
            Guard.NotNull(() => creationScope, creationScope);

            _redisConnection = redisConnection;
            _redisNames = redisNames;
            ConnectionInfo = connectionInfo;
            Scope = creationScope;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisQueueCreation" /> class.
        /// </summary>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="redisConnection">The redis connection.</param>
        /// <param name="redisNames">The redis names.</param>
        /// <param name="creationScope">The creation scope.</param>
        public RedisQueueCreation(IConnectionInformation connectionInfo,
                                  IRedisConnection redisConnection,
                                  RedisNames redisNames,
                                  ICreationScope creationScope)
        {
            Guard.NotNull(() => connectionInfo, connectionInfo);
            Guard.NotNull(() => redisConnection, redisConnection);
            Guard.NotNull(() => redisNames, redisNames);
            Guard.NotNull(() => creationScope, creationScope);

            _redisConnection = redisConnection;
            _redisNames      = redisNames;
            ConnectionInfo   = connectionInfo;
            Scope            = creationScope;
        }
Example #35
0
        public CreateQueueTablesAndSaveConfigurationDecorator(IConnectionInformation connectionInformation,
                                                              ICommandHandlerWithOutput <CreateQueueTablesAndSaveConfigurationCommand <ITable>, QueueCreationResult> decorated,
                                                              IGetFileNameFromConnectionString getFileNameFromConnection,
                                                              DatabaseExists databaseExists)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => decorated, decorated);
            Guard.NotNull(() => getFileNameFromConnection, getFileNameFromConnection);
            Guard.NotNull(() => databaseExists, databaseExists);

            _connectionInformation     = connectionInformation;
            _decorated                 = decorated;
            _getFileNameFromConnection = getFileNameFromConnection;
            _databaseExists            = databaseExists;
        }
Example #36
0
        public override DbObjectCollection CreateCollection(IConnectionInformation info)
        {
            var collection = new DbObjectCollection(info);
            var con        = collection.Initialization();
            var creator    = new ColumnCreator();

            collection.RegisterObjects(con.GetSchema("Tables"), true);
            collection.RegisterObjects(con.GetSchema("Views"), false);
            collection.RegisterMembers(con.GetSchema("Columns"), creator);
            foreach (var obj in collection.Objects.Values
                     .Where(a => a.Kind == EObjectKind.Table && a.Columns.Values.Count(b => b.IsKey) == 1))
            {
                obj.Columns.Values.Where(a => a.IsKey).Single().ColumnIndex = null;
            }
            return(collection);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageProcessingRpcSend{TSendMessage}" /> class.
        /// </summary>
        /// <param name="sendQueue">The send queue.</param>
        /// <param name="rpcTimeoutFactory">The RPC timeout factory.</param>
        /// <param name="headers">The headers.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public MessageProcessingRpcSend(
            IProducerQueue <TSendMessage> sendQueue,
            IRpcTimeoutFactory rpcTimeoutFactory,
            IHeaders headers,
            IConnectionInformation connectionInformation)
        {
            Guard.NotNull(() => sendQueue, sendQueue);
            Guard.NotNull(() => rpcTimeoutFactory, rpcTimeoutFactory);
            Guard.NotNull(() => headers, headers);
            Guard.NotNull(() => connectionInformation, connectionInformation);

            _sendQueue             = sendQueue;
            _rpcTimeoutFactory     = rpcTimeoutFactory;
            _headers               = headers;
            _connectionInformation = connectionInformation;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RollbackMessageCommandHandler" /> class.
 /// </summary>
 /// <param name="getUtcDateQuery">The get UTC date query.</param>
 /// <param name="options">The options.</param>
 /// <param name="tableNameHelper">The table name helper.</param>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="commandCache">The command cache.</param>
 /// <param name="dbFactory">The database factory.</param>
 /// <param name="databaseExists">The database exists.</param>
 public RollbackMessageCommandHandler(IGetTimeFactory getUtcDateQuery,
                                      ISqLiteMessageQueueTransportOptionsFactory options,
                                      ITableNameHelper tableNameHelper,
                                      IConnectionInformation connectionInformation,
                                      IDbCommandStringCache commandCache,
                                      IDbFactory dbFactory,
                                      DatabaseExists databaseExists)
 {
     _getUtcDateQuery       = getUtcDateQuery;
     _options               = new Lazy <SqLiteMessageQueueTransportOptions>(options.Create);
     _tableNameHelper       = tableNameHelper;
     _connectionInformation = connectionInformation;
     _commandCache          = commandCache;
     _rollbackDictionary    = new ConcurrentDictionary <string, string>();
     _dbFactory             = dbFactory;
     _databaseExists        = databaseExists;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ExpressionSerializerDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public ExpressionSerializerDecorator(IMetrics metrics,
            IExpressionSerializer handler,
            IConnectionInformation connectionInformation)
        {
            var name = handler.GetType().Name;
            _methodToBytesTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.ConvertMethodToBytesTimer", Units.Calls);
            _bytesToMethodTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.ConvertBytesToMethodTimer", Units.Calls);
            _resultMethodSizeHistogram = metrics.Histogram($"{connectionInformation.QueueName}.{name}.ConvertMethodToBytesHistogram", Units.Bytes,
                SamplingTypes.LongTerm);

            _functionToBytesTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.ConvertFunctionToBytesTimer", Units.Calls);
            _bytesToFunctionTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.ConvertBytesToFunctionTimer", Units.Calls);
            _resultFunctionSizeHistogram = metrics.Histogram($"{connectionInformation.QueueName}.{name}.ConvertFunctionToBytesHistogram", Units.Bytes,
                SamplingTypes.LongTerm);

            _handler = handler;
        }
Example #40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisQueueStatusProvider" /> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="getTimeFactory">The get time factory.</param>
        /// <param name="pendingQueryHandler">The pending query handler.</param>
        /// <param name="pendingDelayedQueryHandler">The pending delayed query handler.</param>
        /// <param name="workingCountQueryHandler">The working count query handler.</param>
        /// <param name="errorCountQueryHandler">The error count query handler.</param>
        public RedisQueueStatusProvider(IConnectionInformation connectionInformation,
                                        IGetTimeFactory getTimeFactory,
                                        IQueryHandler <GetPendingCountQuery, long> pendingQueryHandler,
                                        IQueryHandler <GetPendingDelayedCountQuery, long> pendingDelayedQueryHandler,
                                        IQueryHandler <GetWorkingCountQuery, long> workingCountQueryHandler,
                                        IQueryHandler <GetErrorCountQuery, long> errorCountQueryHandler) : base(connectionInformation, getTimeFactory)
        {
            Guard.NotNull(() => pendingQueryHandler, pendingQueryHandler);
            Guard.NotNull(() => pendingDelayedQueryHandler, pendingDelayedQueryHandler);
            Guard.NotNull(() => workingCountQueryHandler, workingCountQueryHandler);
            Guard.NotNull(() => errorCountQueryHandler, errorCountQueryHandler);

            _pendingQueryHandler        = pendingQueryHandler;
            _pendingDelayedQueryHandler = pendingDelayedQueryHandler;
            _workingQueryHandler        = workingCountQueryHandler;
            _errorQueryHandler          = errorCountQueryHandler;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisQueueStatusProvider" /> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="getTimeFactory">The get time factory.</param>
        /// <param name="pendingQueryHandler">The pending query handler.</param>
        /// <param name="pendingDelayedQueryHandler">The pending delayed query handler.</param>
        /// <param name="workingCountQueryHandler">The working count query handler.</param>
        /// <param name="errorCountQueryHandler">The error count query handler.</param>
        public RedisQueueStatusProvider(IConnectionInformation connectionInformation,
            IGetTimeFactory getTimeFactory,
            IQueryHandler<GetPendingCountQuery, long> pendingQueryHandler,
            IQueryHandler<GetPendingDelayedCountQuery, long> pendingDelayedQueryHandler,
            IQueryHandler<GetWorkingCountQuery, long> workingCountQueryHandler,
            IQueryHandler<GetErrorCountQuery, long> errorCountQueryHandler) : base(connectionInformation, getTimeFactory)
        {
            Guard.NotNull(() => pendingQueryHandler, pendingQueryHandler);
            Guard.NotNull(() => pendingDelayedQueryHandler, pendingDelayedQueryHandler);
            Guard.NotNull(() => workingCountQueryHandler, workingCountQueryHandler);
            Guard.NotNull(() => errorCountQueryHandler, errorCountQueryHandler);

            _pendingQueryHandler = pendingQueryHandler;
            _pendingDelayedQueryHandler = pendingDelayedQueryHandler;
            _workingQueryHandler = workingCountQueryHandler;
            _errorQueryHandler = errorCountQueryHandler;
        }
Example #42
0
        /// <summary>Initializes a new instance of the <see cref="DataStorage" /> class.</summary>
        /// <param name="jobSchedulerMetaData">The job scheduler meta data.</param>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="receivedMessageFactory">The received message factory.</param>
        /// <param name="messageFactory">The message factory.</param>
        /// <param name="cancelToken">cancel token for stopping</param>
        public DataStorage(
            IJobSchedulerMetaData jobSchedulerMetaData,
            IConnectionInformation connectionInformation,
            IReceivedMessageFactory receivedMessageFactory,
            IMessageFactory messageFactory,
            IQueueCancelWork cancelToken)
        {
            _jobSchedulerMetaData   = jobSchedulerMetaData;
            _connectionInformation  = connectionInformation;
            _receivedMessageFactory = receivedMessageFactory;
            _messageFactory         = messageFactory;
            _cancelToken            = cancelToken;

            if (!Queues.ContainsKey(_connectionInformation))
            {
                Queues.TryAdd(_connectionInformation, new BlockingCollection <Guid>());
            }

            if (!QueueData.ContainsKey(_connectionInformation))
            {
                QueueData.TryAdd(_connectionInformation, new ConcurrentDictionary <Guid, QueueItem>());
            }

            if (!ErrorCounts.ContainsKey(_connectionInformation))
            {
                ErrorCounts.TryAdd(_connectionInformation, new IncrementWrapper());
            }

            if (!DequeueCounts.ContainsKey(_connectionInformation))
            {
                DequeueCounts.TryAdd(_connectionInformation, new IncrementWrapper());
            }

            if (!Jobs.ContainsKey(_connectionInformation))
            {
                Jobs.TryAdd(_connectionInformation, new ConcurrentDictionary <string, Guid>());
            }

            if (!QueueWorking.ContainsKey(_connectionInformation))
            {
                QueueWorking.TryAdd(_connectionInformation, new ConcurrentDictionary <Guid, QueueItem>());
            }

            _complete = false;
        }
        /// <summary>Initializes a new instance of the <see cref="LinqCompileCacheDecorator"/> class.</summary>
        /// <param name="handler">The handler.</param>
        /// <param name="cacheProvider"></param>
        /// <param name="cachePolicy">The cache policy.</param>
        /// <param name="metrics">The metrics.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public LinqCompileCacheDecorator(
            ILinqCompiler handler,
            MemoryCacheProvider cacheProvider,
            ICachePolicy <ILinqCompiler> cachePolicy,
            IMetrics metrics,
            IConnectionInformation connectionInformation)
        {
            _handler      = handler;
            _cacheActions = Policy.Cache <Action <object, object> >(cacheProvider, new SlidingTtl(cachePolicy.SlidingExpiration)
                                                                    , OnCacheGetAction, OnCacheMissAction, (context, s) => { }, (context, s, arg3) => { },
                                                                    (context, s, arg3) => { });

            var name = handler.GetType().Name;

            _counterActionCacheHit    = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqActionCacheHitCounter", Units.Items);
            _counterActionCacheMiss   = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqActionCacheMissCounter", Units.Items);
            _counterActionCacheUnique = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqActionUniqueFlaggedCounter", Units.Items);
        }
Example #44
0
        /// <summary>Initializes a new instance of the <see cref="RedisQueueCreation"/> class.</summary>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="redisConnection">The redis connection.</param>
        /// <param name="redisNames">The redis names.</param>
        /// <param name="creationScope">The creation scope.</param>
        /// <param name="options">Options for queue configuration</param>
        public RedisQueueCreation(IConnectionInformation connectionInfo,
                                  IRedisConnection redisConnection,
                                  RedisNames redisNames,
                                  ICreationScope creationScope,
                                  RedisBaseTransportOptions options)
        {
            Guard.NotNull(() => connectionInfo, connectionInfo);
            Guard.NotNull(() => redisConnection, redisConnection);
            Guard.NotNull(() => redisNames, redisNames);
            Guard.NotNull(() => creationScope, creationScope);
            Guard.NotNull(() => options, options);

            _redisConnection = redisConnection;
            _redisNames      = redisNames;
            ConnectionInfo   = connectionInfo;
            Scope            = creationScope;
            _options         = options;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataStorage" /> class.
        /// </summary>
        /// <param name="jobSchedulerMetaData">The job scheduler meta data.</param>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="receivedMessageFactory">The received message factory.</param>
        /// <param name="messageFactory">The message factory.</param>
        public DataStorage(
            IJobSchedulerMetaData jobSchedulerMetaData,
            IConnectionInformation connectionInformation,
            IReceivedMessageFactory receivedMessageFactory,
            IMessageFactory messageFactory)
        {
            _jobSchedulerMetaData   = jobSchedulerMetaData;
            _connectionInformation  = connectionInformation;
            _receivedMessageFactory = receivedMessageFactory;
            _messageFactory         = messageFactory;

            if (!Queues.ContainsKey(_connectionInformation))
            {
                Queues.TryAdd(_connectionInformation, new ConcurrentQueue <Guid>());
            }

            if (!QueueData.ContainsKey(_connectionInformation))
            {
                QueueData.TryAdd(_connectionInformation, new ConcurrentDictionary <Guid, QueueItem>());
            }

            if (!ErrorCounts.ContainsKey(_connectionInformation))
            {
                ErrorCounts.TryAdd(_connectionInformation, new IncrementWrapper());
            }

            if (!DequeueCounts.ContainsKey(_connectionInformation))
            {
                DequeueCounts.TryAdd(_connectionInformation, new IncrementWrapper());
            }

            if (!Jobs.ContainsKey(_connectionInformation))
            {
                Jobs.TryAdd(_connectionInformation, new ConcurrentDictionary <string, Guid>());
            }

            if (!QueueWorking.ContainsKey(_connectionInformation))
            {
                QueueWorking.TryAdd(_connectionInformation, new ConcurrentDictionary <Guid, QueueItem>());
            }

            Signal = new AutoResetEvent(false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SqliteJobTableCreation" /> class.
        /// </summary>
        /// <param name="queryTableExists">The query table exists.</param>
        /// <param name="createSchema">The create schema.</param>
        /// <param name="createCommand">The create command.</param>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        public SqliteJobTableCreation(IQueryHandler<GetTableExistsQuery, bool> queryTableExists,
            SqliteJobSchema createSchema,
            ICommandHandlerWithOutput<CreateJobTablesCommand, QueueCreationResult> createCommand,
            IConnectionInformation connectionInfo,
            TableNameHelper tableNameHelper
            )
        {
            Guard.NotNull(() => createSchema, createSchema);
            Guard.NotNull(() => queryTableExists, queryTableExists);
            Guard.NotNull(() => createCommand, createCommand);
            Guard.NotNull(() => connectionInfo, connectionInfo);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);

            _createSchema = createSchema;
            _queryTableExists = queryTableExists;
            _createCommand = createCommand;
            _connection = connectionInfo;
            _tableNameHelper = tableNameHelper;
        }
Example #47
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobTableCreation" /> class.
        /// </summary>
        /// <param name="queryTableExists">The query table exists.</param>
        /// <param name="createSchema">The create schema.</param>
        /// <param name="createCommand">The create command.</param>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        public JobTableCreation(IQueryHandler <GetTableExistsQuery, bool> queryTableExists,
                                IJobSchema createSchema,
                                ICommandHandlerWithOutput <CreateJobTablesCommand <ITable>, QueueCreationResult> createCommand,
                                IConnectionInformation connectionInfo,
                                TableNameHelper tableNameHelper
                                )
        {
            Guard.NotNull(() => createSchema, createSchema);
            Guard.NotNull(() => queryTableExists, queryTableExists);
            Guard.NotNull(() => createCommand, createCommand);
            Guard.NotNull(() => connectionInfo, connectionInfo);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);

            _createSchema     = createSchema;
            _queryTableExists = queryTableExists;
            _createCommand    = createCommand;
            _connection       = connectionInfo;
            _tableNameHelper  = tableNameHelper;
        }
Example #48
0
        public override DbObjectCollection CreateCollection(IConnectionInformation info)
        {
            var collection = new DbObjectCollection(info);

            collection.Names.DataType = "DATATYPE";
            var con = collection.Initialization();

            collection.RegisterObjects(collection.GetDataTable(
                                           @"SELECT OWNER TABLE_SCHEMA, TABLE_NAME
FROM ALL_TABLES 
WHERE OWNER NOT IN 
('SYS', 'SYSTEM', 'SYSMAN','CTXSYS', 'MDSYS', 'OLAPSYS', 'ORDSYS', 'OUTLN','WKSYS', 'WMSYS', 'XDB', 'ORDPLUGINS')
AND OWNER NOT LIKE 'APEX%'
ORDER BY OWNER, TABLE_NAME"), true);
            collection.RegisterObjects(collection.GetDataTable(
                                           @"SELECT OWNER TABLE_SCHEMA, VIEW_NAME TABLE_NAME
FROM ALL_VIEWS 
WHERE OWNER NOT IN 
('SYS', 'SYSTEM', 'SYSMAN','CTXSYS', 'MDSYS', 'OLAPSYS', 'ORDSYS', 'OUTLN','WKSYS', 'WMSYS', 'XDB', 'ORDPLUGINS')
AND OWNER NOT LIKE 'APEX%'
ORDER BY OWNER, VIEW_NAME"), false);
            var creator = new DbObjectCollection.ColumnCreator();

            creator.Names.TrueValue = "Y";
            creator.Names.CharName  = "";
            collection.RegisterMembers(collection.GetDataTable(
                                           @"SELECT OWNER TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLUMN_ID AS ID, DATA_TYPE AS DataType, 
DATA_LENGTH AS CHARACTER_MAXIMUM_LENGTH, DATA_PRECISION AS NUMERIC_PRECISION, DATA_SCALE AS NUMERIC_SCALE, 
NULLABLE AS IS_NULLABLE, CHAR_USED, CHAR_LENGTH AS LengthInChars 
FROM ALL_TAB_COLUMNS WHERE OWNER NOT IN 
('SYS', 'SYSTEM', 'SYSMAN','CTXSYS', 'MDSYS', 'OLAPSYS', 'ORDSYS', 'OUTLN','WKSYS', 'WMSYS', 'XDB', 'ORDPLUGINS')
AND OWNER NOT LIKE 'APEX%'
ORDER BY OWNER, TABLE_NAME, ID"), creator);

            var table = collection.GetDataTable(
                @"select  b.OWNER TABLE_SCHEMA,b.TABLE_NAME,b.COLUMN_NAME,b.POSITION ORDINAL_POSITION from all_constraints a
inner join all_cons_columns b ON a.OWNER=b.OWNER and a.CONSTRAINT_NAME=b.CONSTRAINT_NAME
where a.constraint_type='P'");

            collection.RegisterPrimaryKey(table);
            return(collection);
        }
Example #49
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LinqCompileCacheDecorator" /> class.
        /// </summary>
        /// <param name="handler">The handler.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="cachePolicy">The cache policy.</param>
        /// <param name="metrics">The metrics.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public LinqCompileCacheDecorator(
            ILinqCompiler handler,
            ICacheManager <object> cache,
            ICachePolicy <ILinqCompiler> cachePolicy,
            IMetrics metrics,
            IConnectionInformation connectionInformation)
        {
            _handler    = handler;
            _cache      = cache;
            _itemPolicy = cachePolicy;
            var name = handler.GetType().Name;

            _counterActionCacheHit    = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqActionCacheHitCounter", Units.Items);
            _counterActionCacheMiss   = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqActionCacheMissCounter", Units.Items);
            _counterActionCacheUnique = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqActionUniqueFlaggedCounter", Units.Items);

            _counterFunctionCacheHit    = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqFunctionCacheHitCounter", Units.Items);
            _counterFunctionCacheMiss   = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqFunctionCacheMissCounter", Units.Items);
            _counterFunctionCacheUnique = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqFunctionUniqueFlaggedCounter", Units.Items);
        }
Example #50
0
        IConnectionContext IConnectionHandler.OnConnection(IConnectionInformation connectionInfo)
        {
            var inputOptions = new PipeOptions {
                WriterScheduler = InlineScheduler.Default
            };
            var outputOptions = new PipeOptions {
                ReaderScheduler = InlineScheduler.Default
            };

            var context = new HttpConnectionContext <THandler>
            {
                ConnectionId = Guid.NewGuid().ToString(),
                Input        = connectionInfo.PipeFactory.Create(inputOptions),
                Output       = connectionInfo.PipeFactory.Create(outputOptions)
            };

            _ = context.ExecuteAsync();

            return(context);
        }
        public IConnectionContext OnConnection(IConnectionInformation connectionInfo)
        {
            var inputOptions = new PipeOptions {
                WriterScheduler = connectionInfo.InputWriterScheduler
            };
            var outputOptions = new PipeOptions {
                ReaderScheduler = connectionInfo.OutputReaderScheduler
            };

            var context = new HttpConnectionContext
            {
                ConnectionId = Guid.NewGuid().ToString(),
                Input        = connectionInfo.PipeFactory.Create(inputOptions),
                Output       = connectionInfo.PipeFactory.Create(outputOptions),
            };

            _ = context.ExecuteAsync();

            return(context);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LinqCompileCacheDecorator" /> class.
        /// </summary>
        /// <param name="handler">The handler.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="cachePolicy">The cache policy.</param>
        /// <param name="metrics">The metrics.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public LinqCompileCacheDecorator(
            ILinqCompiler handler,
            ObjectCache cache,
            ICachePolicy<ILinqCompiler> cachePolicy,
            IMetrics metrics,
             IConnectionInformation connectionInformation)
        {
            _handler = handler;
            _cache = cache;
            _itemPolicy = new CacheItemPolicy {SlidingExpiration = cachePolicy.SlidingExpiration};
            var name = handler.GetType().Name;

            _counterActionCacheHit = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqActionCacheHitCounter", Units.Items);
            _counterActionCacheMiss = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqActionCacheMissCounter", Units.Items);
            _counterActionCacheUnique = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqActionUniqueFlaggedCounter", Units.Items);

            _counterFunctionCacheHit = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqFunctionCacheHiCountert", Units.Items);
            _counterFunctionCacheMiss = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqFunctionCacheMissCounter", Units.Items);
            _counterFunctionCacheUnique = metrics.Counter($"{connectionInformation.QueueName}.{name}.LinqFunctionUniqueFlaggedCounter", Units.Items);

        }
 public void AddConnectionIfNeeded(IConnectionInformation connection)
 {
     var fileName = GetFileNameFromConnectionString.GetFileName(connection.ConnectionString);
     if (!fileName.IsInMemory) return;
     if (_connections.ContainsKey(connection.ConnectionString)) return;
     var sqlConnection = new SQLiteConnection(connection.ConnectionString);
     try
     {
         sqlConnection.Open();
     }
     catch (Exception) //resource leak possible on open
     {
         sqlConnection.Dispose();
         throw;
     }
     if (!_connections.TryAdd(connection.ConnectionString, sqlConnection))
     {
         //already added by another thread
         sqlConnection.Dispose();
     }
 }
Example #54
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageInterceptorDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public MessageInterceptorDecorator(IMetrics metrics,
                                           IMessageInterceptor handler,
                                           IConnectionInformation connectionInformation)
        {
            _handler = handler;
            var name = handler.GetType().Name;

            _metricTimerBytes =
                metrics.Timer($"{connectionInformation.QueueName}.{name}.BytesToMessageTimer", Units.Calls);

            _metricTimerMessage =
                metrics.Timer($"{connectionInformation.QueueName}.{name}.MessageToBytesTimer", Units.Calls);

            _metricHistogram = metrics.Histogram($"{connectionInformation.QueueName}.{name}.MessageToBytesHistogram", Units.Bytes,
                                                 SamplingTypes.LongTerm);

            _metricHistogramDelta = metrics.Histogram($"{connectionInformation.QueueName}.{name}.MessageToBytesDeltaHistogram", Units.Bytes,
                                                      SamplingTypes.LongTerm);

            _metricHistogramOptOut = metrics.Histogram($"{connectionInformation.QueueName}.{name}.OptOutOfGraphHistogram",
                                                       Units.Bytes, SamplingTypes.LongTerm);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LiteDbConnectionManager"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="scope">The scope.</param>
        public LiteDbConnectionManager(IConnectionInformation connectionInformation, ICreationScope scope)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => scope, scope);
            _connectionInformation = connectionInformation;

            var builder = new LiteDB.ConnectionString(_connectionInformation.ConnectionString);

            _shared = builder.Connection == ConnectionType.Shared;

            var existingScopeConnection = scope.GetDisposable <LiteDbConnectionManager>();

            if (existingScopeConnection != null)
            {
                _db = existingScopeConnection.GetDatabase().Database;
                _shouldDisposeDirectConnection = false;
            }
            else
            {
                _shouldDisposeDirectConnection = true;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageInterceptorDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public MessageInterceptorDecorator(IMetrics metrics,
            IMessageInterceptor handler,
            IConnectionInformation connectionInformation)
        {
            _handler = handler;
            var name = handler.GetType().Name;

            _metricTimerBytes =
                metrics.Timer($"{connectionInformation.QueueName}.{name}.BytesToMessageTimer", Units.Calls);

            _metricTimerMessage =
                metrics.Timer($"{connectionInformation.QueueName}.{name}.MessageToBytesTimer", Units.Calls);

            _metricHistogram = metrics.Histogram($"{connectionInformation.QueueName}.{name}.MessageToBytesHistogram", Units.Bytes,
                SamplingTypes.LongTerm);

            _metricHistogramDelta = metrics.Histogram($"{connectionInformation.QueueName}.{name}.MessageToBytesDeltaHistogram", Units.Bytes,
                SamplingTypes.LongTerm);

            _metricHistogramOptOut = metrics.Histogram($"{connectionInformation.QueueName}.{name}.OptOutOfGraphHistogram",
                Units.Bytes, SamplingTypes.LongTerm);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlMessageQueueCreation" /> class.
        /// </summary>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="queryTableExists">The query table exists.</param>
        /// <param name="options">The options.</param>
        /// <param name="createSchema">The create schema.</param>
        /// <param name="createCommand">The create command.</param>
        /// <param name="deleteCommand">The delete command.</param>
        /// <param name="creationScope">The creation scope.</param>
        public PostgreSqlMessageQueueCreation(IConnectionInformation connectionInfo, IQueryHandler <GetTableExistsQuery, bool> queryTableExists,
                                              IPostgreSqlMessageQueueTransportOptionsFactory options,
                                              PostgreSqlMessageQueueSchema createSchema,
                                              ICommandHandlerWithOutput <CreateQueueTablesAndSaveConfigurationCommand <ITable>, QueueCreationResult> createCommand,
                                              ICommandHandlerWithOutput <DeleteQueueTablesCommand, QueueRemoveResult> deleteCommand,
                                              ICreationScope creationScope
                                              )
        {
            Guard.NotNull(() => options, options);
            Guard.NotNull(() => createSchema, createSchema);
            Guard.NotNull(() => queryTableExists, queryTableExists);
            Guard.NotNull(() => createCommand, createCommand);
            Guard.NotNull(() => deleteCommand, deleteCommand);
            Guard.NotNull(() => creationScope, creationScope);

            _options          = new Lazy <PostgreSqlMessageQueueTransportOptions>(options.Create);
            _createSchema     = createSchema;
            _queryTableExists = queryTableExists;
            _createCommand    = createCommand;
            _deleteCommand    = deleteCommand;
            ConnectionInfo    = connectionInfo;
            Scope             = creationScope;
        }
Example #58
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReceiveMessageQueryHandler" /> class.
        /// </summary>
        /// <param name="optionsFactory">The options factory.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="buildDequeueCommand">The build dequeue command.</param>
        /// <param name="messageDeQueue">The message de queue.</param>
        /// <param name="dbFactory">The transaction factory.</param>
        /// <param name="databaseExists">The database exists.</param>
        public ReceiveMessageQueryHandler(ISqLiteMessageQueueTransportOptionsFactory optionsFactory,
                                          TableNameHelper tableNameHelper,
                                          IConnectionInformation connectionInformation,
                                          BuildDequeueCommand buildDequeueCommand,
                                          MessageDeQueue messageDeQueue,
                                          IDbFactory dbFactory,
                                          DatabaseExists databaseExists)
        {
            Guard.NotNull(() => optionsFactory, optionsFactory);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => buildDequeueCommand, buildDequeueCommand);
            Guard.NotNull(() => messageDeQueue, messageDeQueue);
            Guard.NotNull(() => databaseExists, databaseExists);
            Guard.NotNull(() => dbFactory, dbFactory);

            _options               = new Lazy <SqLiteMessageQueueTransportOptions>(optionsFactory.Create);
            _tableNameHelper       = tableNameHelper;
            _connectionInformation = connectionInformation;
            _buildDequeueCommand   = buildDequeueCommand;
            _messageDeQueue        = messageDeQueue;
            _dbFactory             = dbFactory;
            _databaseExists        = databaseExists;
        }
Example #59
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GetQueueOptionsQueryHandler{TTransportOptions}" /> class.
        /// </summary>
        /// <param name="serializer">The serializer.</param>
        /// <param name="tableExists">The table exists.</param>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="prepareQuery">The prepare query.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        /// <param name="dbConnectionFactory">The database connection factory.</param>
        /// <param name="readColumn">The read column.</param>
        public GetQueueOptionsQueryHandler(IInternalSerializer serializer,
                                           IQueryHandler <GetTableExistsQuery, bool> tableExists,
                                           IConnectionInformation connectionInformation,
                                           IPrepareQueryHandler <GetQueueOptionsQuery <TTransportOptions>, TTransportOptions> prepareQuery,
                                           ITableNameHelper tableNameHelper,
                                           IDbConnectionFactory dbConnectionFactory,
                                           IReadColumn readColumn)
        {
            Guard.NotNull(() => serializer, serializer);
            Guard.NotNull(() => tableExists, tableExists);
            Guard.NotNull(() => prepareQuery, prepareQuery);
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => dbConnectionFactory, dbConnectionFactory);
            Guard.NotNull(() => readColumn, readColumn);

            _serializer            = serializer;
            _tableExists           = tableExists;
            _connectionInformation = connectionInformation;
            _prepareQuery          = prepareQuery;
            _tableNameHelper       = tableNameHelper;
            _dbConnectionFactory   = dbConnectionFactory;
            _readColumn            = readColumn;
        }
Example #60
0
        public override DbObjectCollection CreateCollection(IConnectionInformation info)
        {
            var collection = new DbObjectCollection(info);

            collection.Names.DataTypeKey = "NativeDataType";
            var con     = collection.Initialization();
            var creator = new DbObjectCollection.ColumnCreator();

            collection.RegisterObjects(con.GetSchema("Tables"), true, "TABLE_TYPE = 'TABLE'");
            collection.RegisterObjects(con.GetSchema("Views"), false);

            collection.RegisterMembers(con.GetSchema("Columns"), creator);

            var table = con.GetSchema("Indexes");

            var rows = table.Select("PRIMARY_KEY=0");

            foreach (var row in rows)
            {
                table.Rows.Remove(row);
            }
            collection.RegisterPrimaryKey(table);
            return(collection);
        }