コード例 #1
1
ファイル: Connection.cs プロジェクト: Djohnnie/Sonarr
        public Connection(IMessageBus newMessageBus,
                          IJsonSerializer jsonSerializer,
                          string baseSignal,
                          string connectionId,
                          IList<string> signals,
                          IList<string> groups,
                          ITraceManager traceManager,
                          IAckHandler ackHandler,
                          IPerformanceCounterManager performanceCounterManager,
                          IProtectedData protectedData)
        {
            if (traceManager == null)
            {
                throw new ArgumentNullException("traceManager");
            }

            _bus = newMessageBus;
            _serializer = jsonSerializer;
            _baseSignal = baseSignal;
            _connectionId = connectionId;
            _signals = new List<string>(signals.Concat(groups));
            _groups = new DiffSet<string>(groups);
            _traceSource = traceManager["SignalR.Connection"];
            _ackHandler = ackHandler;
            _counters = performanceCounterManager;
            _protectedData = protectedData;
        }
コード例 #2
1
        public Connection(IMessageBus newMessageBus,
                          JsonSerializer jsonSerializer,
                          string baseSignal,
                          string connectionId,
                          IList<string> signals,
                          IList<string> groups,
                          ILoggerFactory loggerFactory,
                          IAckHandler ackHandler,
                          IPerformanceCounterManager performanceCounterManager,
                          IProtectedData protectedData,
                          IMemoryPool pool)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException("loggerFactory");
            }

            _bus = newMessageBus;
            _serializer = jsonSerializer;
            _baseSignal = baseSignal;
            _connectionId = connectionId;
            _signals = new List<string>(signals.Concat(groups));
            _groups = new DiffSet<string>(groups);
            _logger = loggerFactory.CreateLogger<Connection>();
            _ackHandler = ackHandler;
            _counters = performanceCounterManager;
            _protectedData = protectedData;
            _excludeMessage = m => ExcludeMessage(m);
            _pool = pool;
        }
コード例 #3
0
 public MessageRouter(ISocketFactory socketFactory,
                      IInternalRoutingTable internalRoutingTable,
                      IExternalRoutingTable externalRoutingTable,
                      IScaleOutConfigurationProvider scaleOutConfigurationProvider,
                      IClusterServices clusterServices,
                      IServiceMessageHandlerRegistry serviceMessageHandlerRegistry,
                      IPerformanceCounterManager <KinoPerformanceCounters> performanceCounterManager,
                      ISecurityProvider securityProvider,
                      ILocalSocket <IMessage> localRouterSocket,
                      ILocalReceivingSocket <InternalRouteRegistration> internalRegistrationsReceiver,
                      IInternalMessageRouteRegistrationHandler internalRegistrationHandler,
                      IRoundRobinDestinationList roundRobinDestinationList,
                      ILogger logger)
 {
     this.logger                        = logger;
     this.socketFactory                 = socketFactory;
     this.internalRoutingTable          = internalRoutingTable;
     this.externalRoutingTable          = externalRoutingTable;
     this.scaleOutConfigurationProvider = scaleOutConfigurationProvider;
     this.clusterServices               = clusterServices;
     this.serviceMessageHandlerRegistry = serviceMessageHandlerRegistry;
     this.performanceCounterManager     = performanceCounterManager;
     this.securityProvider              = securityProvider;
     this.localRouterSocket             = localRouterSocket;
     this.localRouterSocket.SendRate    = performanceCounterManager.GetCounter(KinoPerformanceCounters.MessageRouterLocalSocketSendRate);
     this.localRouterSocket.ReceiveRate = performanceCounterManager.GetCounter(KinoPerformanceCounters.MessageRouterLocalSocketReceiveRate);
     this.internalRegistrationsReceiver = internalRegistrationsReceiver;
     this.internalRegistrationHandler   = internalRegistrationHandler;
     this.roundRobinDestinationList     = roundRobinDestinationList;
 }
コード例 #4
0
 public TransportDisconnectBase(HostContext context, IJsonSerializer jsonSerializer, ITransportHeartBeat heartBeat, IPerformanceCounterManager performanceCounterManager)
 {
     _context = context;
     _jsonSerializer = jsonSerializer;
     _heartBeat = heartBeat;
     _counters = performanceCounterManager;
 }
コード例 #5
0
ファイル: MessageBroker.cs プロジェクト: TerenceLewis/SignalR
        public MessageBroker(ConcurrentDictionary <string, Topic> topics, IPerformanceCounterManager performanceCounterManager)
        {
            _topics   = topics;
            _counters = performanceCounterManager;

            _timer = new Timer(_ => OnTimer(), state: null, dueTime: CheckWorkInterval, period: CheckWorkInterval);
        }
コード例 #6
0
        public ScaleoutSubscription(string identity,
                                    IList <string> eventKeys,
                                    string cursor,
                                    IList <ScaleoutMappingStore> stores,
                                    Func <MessageResult, object, Task <bool> > callback,
                                    int maxMessages,
                                    IPerformanceCounterManager counters,
                                    object state)
            : base(identity, eventKeys, callback, maxMessages, counters, state)
        {
            if (stores == null)
            {
                throw new ArgumentNullException("stores");
            }

            _stores = stores;

            List <Cursor> cursors = null;

            if (String.IsNullOrEmpty(cursor))
            {
                cursors = new List <Cursor>(stores.Count);
                for (int i = 0; i < stores.Count; i++)
                {
                    cursors.Add(new Cursor(i.ToString(CultureInfo.InvariantCulture), stores[i].MaxKey));
                }
            }
            else
            {
                cursors = Cursor.GetCursors(cursor);
            }

            _cursors = cursors;
        }
コード例 #7
0
 public TransportDisconnectBase(HostContext context, IJsonSerializer jsonSerializer, ITransportHeartBeat heartBeat, IPerformanceCounterManager performanceCounterManager)
 {
     _context        = context;
     _jsonSerializer = jsonSerializer;
     _heartBeat      = heartBeat;
     _counters       = performanceCounterManager;
 }
コード例 #8
0
        public ScaleoutStreamManager(Func<int, IList<Message>, Task> send,
                                     Action<int, ulong, ScaleoutMessage> receive,
                                     int streamCount,
                                     TraceSource trace,
                                     IPerformanceCounterManager performanceCounters,
                                     ScaleoutConfiguration configuration)
        {
            if (configuration.QueueBehavior != QueuingBehavior.Disabled && configuration.MaxQueueLength == 0)
            {
                throw new InvalidOperationException(Resources.Error_ScaleoutQueuingConfig);
            }

            _streams = new ScaleoutStream[streamCount];
            _send = send;
            _receive = receive;

            var receiveMapping = new ScaleoutMappingStore[streamCount];

            performanceCounters.ScaleoutStreamCountTotal.RawValue = streamCount;
            performanceCounters.ScaleoutStreamCountBuffering.RawValue = streamCount;
            performanceCounters.ScaleoutStreamCountOpen.RawValue = 0;

            for (int i = 0; i < streamCount; i++)
            {
                _streams[i] = new ScaleoutStream(trace, "Stream(" + i + ")", configuration.QueueBehavior, configuration.MaxQueueLength, performanceCounters);
                receiveMapping[i] = new ScaleoutMappingStore();
            }

            Streams = new ReadOnlyCollection<ScaleoutMappingStore>(receiveMapping);
        }
コード例 #9
0
        protected TransportDisconnectBase(HostContext context, IJsonSerializer jsonSerializer, ITransportHeartbeat heartbeat, IPerformanceCounterManager performanceCounterManager, ITraceManager traceManager)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (jsonSerializer == null)
            {
                throw new ArgumentNullException("jsonSerializer");
            }

            if (heartbeat == null)
            {
                throw new ArgumentNullException("heartbeat");
            }

            if (performanceCounterManager == null)
            {
                throw new ArgumentNullException("performanceCounterManager");
            }

            if (traceManager == null)
            {
                throw new ArgumentNullException("traceManager");
            }

            _context = context;
            _jsonSerializer = jsonSerializer;
            _heartbeat = heartbeat;
            _counters = performanceCounterManager;

            _trace = traceManager["SignalR.Transports." + GetType().Name];
        }
コード例 #10
0
        public ScaleoutStreamManager(Func<int, IList<Message>, Task> send,
                                     Action<int, ulong, ScaleoutMessage> receive,
                                     int streamCount,
                                     TraceSource trace,
                                     IPerformanceCounterManager performanceCounters,
                                     ScaleoutConfiguration configuration)
        {
            _streams = new ScaleoutStream[streamCount];
            _send = send;
            _receive = receive;

            var receiveMapping = new ScaleoutMappingStore[streamCount];

            performanceCounters.ScaleoutStreamCountTotal.RawValue = streamCount;
            performanceCounters.ScaleoutStreamCountBuffering.RawValue = streamCount;
            performanceCounters.ScaleoutStreamCountOpen.RawValue = 0;

            for (int i = 0; i < streamCount; i++)
            {
                _streams[i] = new ScaleoutStream(trace, "Stream(" + i + ")", configuration.MaxQueueLength, performanceCounters);
                receiveMapping[i] = new ScaleoutMappingStore();
            }

            Streams = new ReadOnlyCollection<ScaleoutMappingStore>(receiveMapping);
        }
コード例 #11
0
ファイル: Connection.cs プロジェクト: titan04/Sonarr
        public Connection(IMessageBus newMessageBus,
                          IJsonSerializer jsonSerializer,
                          string baseSignal,
                          string connectionId,
                          IList <string> signals,
                          IList <string> groups,
                          ITraceManager traceManager,
                          IAckHandler ackHandler,
                          IPerformanceCounterManager performanceCounterManager,
                          IProtectedData protectedData)
        {
            if (traceManager == null)
            {
                throw new ArgumentNullException("traceManager");
            }

            _bus           = newMessageBus;
            _serializer    = jsonSerializer;
            _baseSignal    = baseSignal;
            _connectionId  = connectionId;
            _signals       = new List <string>(signals.Concat(groups));
            _groups        = new DiffSet <string>(groups);
            _traceSource   = traceManager["SignalR.Connection"];
            _ackHandler    = ackHandler;
            _counters      = performanceCounterManager;
            _protectedData = protectedData;
        }
コード例 #12
0
        public ServiceBusMessageBus(IStringMinifier stringMinifier,
                                    ILoggerFactory loggerFactory,
                                    IPerformanceCounterManager performanceCounterManager,
                                    IOptions <MessageBusOptions> optionsAccessor,
                                    IOptions <ServiceBusScaleoutOptions> scaleoutConfigurationAccessor)
            : base(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor, scaleoutConfigurationAccessor)
        {
            var configuration = scaleoutConfigurationAccessor.Value;

            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (String.IsNullOrEmpty(configuration.TopicPrefix))
            {
                throw new InvalidOperationException("TopixPrefix is invalid");
            }

            _logger = loggerFactory.CreateLogger <ServiceBusMessageBus>();

            _connection = new ServiceBusConnection(configuration, _logger);

            _topics = Enumerable.Range(0, configuration.TopicCount)
                      .Select(topicIndex => SignalRTopicPrefix + "_" + configuration.TopicPrefix + "_" + topicIndex)
                      .ToArray();

            _connectionContext = new ServiceBusConnectionContext(configuration, _topics, _logger, OnMessage, OnError, Open);

            ThreadPool.QueueUserWorkItem(Subscribe);
        }
コード例 #13
0
        public ScaleoutStreamManager(Func <int, IList <Message>, Task> send,
                                     Action <int, ulong, ScaleoutMessage> receive,
                                     int streamCount,
                                     TraceSource trace,
                                     IPerformanceCounterManager performanceCounters,
                                     ScaleoutConfiguration configuration)
        {
            if (configuration.QueueBehavior != QueuingBehavior.Disabled && configuration.MaxQueueLength == 0)
            {
                throw new InvalidOperationException(Resources.Error_ScaleoutQueuingConfig);
            }

            _streams = new ScaleoutStream[streamCount];
            _send    = send;
            _receive = receive;

            var receiveMapping = new ScaleoutMappingStore[streamCount];

            performanceCounters.ScaleoutStreamCountTotal.RawValue     = streamCount;
            performanceCounters.ScaleoutStreamCountBuffering.RawValue = streamCount;
            performanceCounters.ScaleoutStreamCountOpen.RawValue      = 0;

            for (int i = 0; i < streamCount; i++)
            {
                _streams[i]       = new ScaleoutStream(trace, "Stream(" + i + ")", configuration.QueueBehavior, configuration.MaxQueueLength, performanceCounters);
                receiveMapping[i] = new ScaleoutMappingStore();
            }

            Streams = new ReadOnlyCollection <ScaleoutMappingStore>(receiveMapping);
        }
コード例 #14
0
        protected TransportDisconnectBase(HostContext context, ITransportHeartbeat heartbeat, IPerformanceCounterManager performanceCounterManager, ITraceManager traceManager)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (heartbeat == null)
            {
                throw new ArgumentNullException("heartbeat");
            }

            if (performanceCounterManager == null)
            {
                throw new ArgumentNullException("performanceCounterManager");
            }

            if (traceManager == null)
            {
                throw new ArgumentNullException("traceManager");
            }

            _context   = context;
            _heartbeat = heartbeat;
            _counters  = performanceCounterManager;

            // Queue to protect against overlapping writes to the underlying response stream
            WriteQueue = new TaskQueue();

            _trace = traceManager["SignalR.Transports." + GetType().Name];
        }
コード例 #15
0
        public ScaleoutSubscription(string identity,
                                    IEnumerable<string> eventKeys,
                                    string cursor,
                                    ConcurrentDictionary<string, Linktionary<ulong, ScaleoutMapping>> streamMappings,
                                    Func<MessageResult, Task<bool>> callback,
                                    int maxMessages,
                                    IPerformanceCounterManager counters)
            : base(identity, eventKeys, callback, maxMessages, counters)
        {
            _streams = streamMappings;

            IEnumerable<Cursor> cursors = null;

            if (cursor == null)
            {
                cursors = from key in _streams.Keys
                          select new Cursor(key, GetCursorId(key));
            }
            else
            {
                cursors = Cursor.GetCursors(cursor);
            }

            _cursors = new List<Cursor>(cursors);
        }
コード例 #16
0
        public MessageBroker(ConcurrentDictionary<string, Topic> topics, IPerformanceCounterManager performanceCounterManager)
        {
            _topics = topics;
            _counters = performanceCounterManager;

            _timer = new Timer(_ => OnTimer(), state: null, dueTime: CheckWorkInterval, period: CheckWorkInterval);
        }
コード例 #17
0
        public ScaleoutSubscription(string identity,
                                    IList<string> eventKeys,
                                    string cursor,
                                    IList<ScaleoutMappingStore> stores,
                                    Func<MessageResult, object, Task<bool>> callback,
                                    int maxMessages,
                                    IPerformanceCounterManager counters,
                                    object state)
            : base(identity, eventKeys, callback, maxMessages, counters, state)
        {
            if (stores == null)
            {
                throw new ArgumentNullException("stores");
            }

            _stores = stores;

            List<Cursor> cursors = null;

            if (String.IsNullOrEmpty(cursor))
            {
                cursors = new List<Cursor>(stores.Count);
                for (int i = 0; i < stores.Count; i++)
                {
                    cursors.Add(new Cursor(i.ToString(CultureInfo.InvariantCulture), stores[i].MaxKey));
                }
            }
            else
            {
                cursors = Cursor.GetCursors(cursor);
            }

            _cursors = cursors;
        }
コード例 #18
0
        public Connection(IMessageBus newMessageBus,
                          JsonSerializer jsonSerializer,
                          string baseSignal,
                          string connectionId,
                          IList <string> signals,
                          IList <string> groups,
                          ILoggerFactory loggerFactory,
                          IAckHandler ackHandler,
                          IPerformanceCounterManager performanceCounterManager,
                          IProtectedData protectedData,
                          IMemoryPool pool)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException("loggerFactory");
            }

            _bus            = newMessageBus;
            _serializer     = jsonSerializer;
            _baseSignal     = baseSignal;
            _connectionId   = connectionId;
            _signals        = new List <string>(signals.Concat(groups));
            _groups         = new DiffSet <string>(groups);
            _logger         = loggerFactory.CreateLogger <Connection>();
            _ackHandler     = ackHandler;
            _counters       = performanceCounterManager;
            _protectedData  = protectedData;
            _excludeMessage = m => ExcludeMessage(m);
            _pool           = pool;
        }
コード例 #19
0
        public ScaleoutSubscription(string identity,
                                    IEnumerable <string> eventKeys,
                                    string cursor,
                                    ConcurrentDictionary <string, Linktionary <ulong, ScaleoutMapping> > streamMappings,
                                    Func <MessageResult, Task <bool> > callback,
                                    int maxMessages,
                                    IPerformanceCounterManager counters)
            : base(identity, eventKeys, callback, maxMessages, counters)
        {
            _streams = streamMappings;

            IEnumerable <Cursor> cursors = null;

            if (cursor == null)
            {
                cursors = from key in _streams.Keys
                          select new Cursor
                {
                    Key = key,
                    Id  = GetCursorId(key)
                };
            }
            else
            {
                cursors = Cursor.GetCursors(cursor);
            }

            _cursors = new List <Cursor>(cursors);
        }
コード例 #20
0
        internal RedisMessageBus(IStringMinifier stringMinifier,
                                     ILoggerFactory loggerFactory,
                                     IPerformanceCounterManager performanceCounterManager,
                                     IOptions<MessageBusOptions> optionsAccessor,
                                     IOptions<RedisScaleoutOptions> scaleoutConfigurationAccessor,
                                     IRedisConnection connection,
                                     bool connectAutomatically)
            : base(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor, scaleoutConfigurationAccessor)
        {
            _connectionString = scaleoutConfigurationAccessor.Options.ConnectionString;
            _db = scaleoutConfigurationAccessor.Options.Database;
            _key = scaleoutConfigurationAccessor.Options.EventKey;

            _connection = connection;

            _logger = loggerFactory.CreateLogger<RedisMessageBus>();

            ReconnectDelay = TimeSpan.FromSeconds(2);

            if (connectAutomatically)
            {
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    var ignore = ConnectWithRetry();
                });
            }
        }
コード例 #21
0
 public TestMessageBus(IStringMinifier stringMinifier,
                       ILoggerFactory loggerFactory,
                       IPerformanceCounterManager performanceCounterManager,
                       IOptions <MessageBusOptions> optionsAccessor) :
     base(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor)
 {
 }
コード例 #22
0
        protected TransportDisconnectBase(HostContext context, ITransportHeartbeat heartbeat, IPerformanceCounterManager performanceCounterManager, ITraceManager traceManager)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (heartbeat == null)
            {
                throw new ArgumentNullException("heartbeat");
            }

            if (performanceCounterManager == null)
            {
                throw new ArgumentNullException("performanceCounterManager");
            }

            if (traceManager == null)
            {
                throw new ArgumentNullException("traceManager");
            }

            _context = context;
            _heartbeat = heartbeat;
            _counters = performanceCounterManager;

            // Queue to protect against overlapping writes to the underlying response stream
            WriteQueue = new TaskQueue();

            _trace = traceManager["SignalR.Transports." + GetType().Name];
        }
コード例 #23
0
        internal RedisMessageBus(IStringMinifier stringMinifier,
                                 ILoggerFactory loggerFactory,
                                 IPerformanceCounterManager performanceCounterManager,
                                 IOptions <MessageBusOptions> optionsAccessor,
                                 IOptions <RedisScaleoutOptions> scaleoutConfigurationAccessor,
                                 IRedisConnection connection,
                                 bool connectAutomatically)
            : base(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor, scaleoutConfigurationAccessor)
        {
            _connectionString = scaleoutConfigurationAccessor.Options.ConnectionString;
            _db  = scaleoutConfigurationAccessor.Options.Database;
            _key = scaleoutConfigurationAccessor.Options.EventKey;

            _connection = connection;

            _logger = loggerFactory.CreateLogger <RedisMessageBus>();

            ReconnectDelay = TimeSpan.FromSeconds(2);

            if (connectAutomatically)
            {
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    var ignore = ConnectWithRetry();
                });
            }
        }
コード例 #24
0
        public ScaleoutStreamManager(Func <int, IList <Message>, Task> send,
                                     Action <int, ulong, ScaleoutMessage> receive,
                                     int streamCount,
                                     TraceSource trace,
                                     IPerformanceCounterManager performanceCounters,
                                     ScaleoutConfiguration configuration)
        {
            _streams = new ScaleoutStream[streamCount];
            _send    = send;
            _receive = receive;

            var receiveMapping = new ScaleoutMappingStore[streamCount];

            performanceCounters.ScaleoutStreamCountTotal.RawValue     = streamCount;
            performanceCounters.ScaleoutStreamCountBuffering.RawValue = streamCount;
            performanceCounters.ScaleoutStreamCountOpen.RawValue      = 0;

            for (int i = 0; i < streamCount; i++)
            {
                _streams[i]       = new ScaleoutStream(trace, "Stream(" + i + ")", configuration.MaxQueueLength, performanceCounters);
                receiveMapping[i] = new ScaleoutMappingStore();
            }

            Streams = new ReadOnlyCollection <ScaleoutMappingStore>(receiveMapping);
        }
コード例 #25
0
 public RedisMessageBus(IStringMinifier stringMinifier,
                        ILoggerFactory loggerFactory,
                        IPerformanceCounterManager performanceCounterManager,
                        IOptions <MessageBusOptions> optionsAccessor,
                        IOptions <RedisScaleoutOptions> scaleoutConfigurationAccessor, IRedisConnection connection)
     : this(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor, scaleoutConfigurationAccessor, connection, true)
 {
 }
コード例 #26
0
 public WebSocketTransport(HostContext context,
                           IJsonSerializer serializer,
                           ITransportHeartBeat heartBeat,
                           IPerformanceCounterManager performanceCounterWriter)
     : base(context, serializer, heartBeat, performanceCounterWriter)
 {
     _context = context;
 }
コード例 #27
0
 public RedisMessageBus(IStringMinifier stringMinifier,
                              ILoggerFactory loggerFactory,
                              IPerformanceCounterManager performanceCounterManager,
                              IOptions<MessageBusOptions> optionsAccessor,
                              IOptions<RedisScaleoutOptions> scaleoutConfigurationAccessor, IRedisConnection connection)
     : this(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor, scaleoutConfigurationAccessor, connection, true)
 {
 }
コード例 #28
0
 public TestScaleoutBus(IStringMinifier stringMinifier,
                        ILoggerFactory loggerFactory,
                        IPerformanceCounterManager performanceCounterManager,
                        IOptionsAccessor <SignalROptions> optionsAccessor,
                        IOptionsAccessor <ScaleoutConfiguration> scaleoutConfigurationAccessor)
     : base(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor, scaleoutConfigurationAccessor)
 {
 }
コード例 #29
0
 /// <summary>
 /// Creates a new instance of the SqlMessageBus class.
 /// </summary>
 /// <param name="resolver">The resolver to use.</param>
 /// <param name="configuration">The SQL scale-out configuration options.</param>
 public SqlMessageBus(IStringMinifier stringMinifier,
                      ILoggerFactory loggerFactory,
                      IPerformanceCounterManager performanceCounterManager,
                      IOptions <MessageBusOptions> optionsAccessor,
                      IOptions <SqlScaleoutOptions> scaleoutOptionsAccessor)
     : this(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor, scaleoutOptionsAccessor, SqlClientFactory.Instance.AsIDbProviderFactory())
 {
 }
コード例 #30
0
 /// <summary>
 /// Creates a new instance of the SqlMessageBus class.
 /// </summary>
 /// <param name="resolver">The resolver to use.</param>
 /// <param name="configuration">The SQL scale-out configuration options.</param>
 public SqlMessageBus(IStringMinifier stringMinifier,
                              ILoggerFactory loggerFactory,
                              IPerformanceCounterManager performanceCounterManager,
                              IOptions<MessageBusOptions> optionsAccessor,
                              IOptions<SqlScaleoutOptions> scaleoutOptionsAccessor)
     : this(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor, scaleoutOptionsAccessor, SqlClientFactory.Instance.AsIDbProviderFactory())
 {
 }
コード例 #31
0
 public WebSocketTransport(HostContext context, 
                           IJsonSerializer serializer, 
                           ITransportHeartBeat heartBeat,
                           IPerformanceCounterManager performanceCounterWriter)
     : base(context, serializer, heartBeat, performanceCounterWriter)
 {
     _context = context;
 }
コード例 #32
0
        protected override IPerformanceCounter[] GetPerformanceCounters(IPerformanceCounterManager counterManager)
        {
            if (RunData.Host != "External")
            {
                return(base.GetPerformanceCounters(counterManager));
            }

            return(new IPerformanceCounter[0]);
        }
コード例 #33
0
        public ScaleoutSubscription(string identity,
                                    IList <string> eventKeys,
                                    string cursor,
                                    IList <ScaleoutMappingStore> streams,
                                    Func <MessageResult, object, Task <bool> > callback,
                                    int maxMessages,
                                    ITraceManager traceManager,
                                    IPerformanceCounterManager counters,
                                    object state)
            : base(identity, eventKeys, callback, maxMessages, counters, state)
        {
            if (streams == null)
            {
                throw new ArgumentNullException("streams");
            }

            if (traceManager == null)
            {
                throw new ArgumentNullException(nameof(traceManager));
            }

            _streams = streams;

            List <Cursor> cursors = null;

            if (String.IsNullOrEmpty(cursor))
            {
                cursors = new List <Cursor>();
            }
            else
            {
                cursors = Cursor.GetCursors(cursor, _scaleoutCursorPrefix);

                // If the cursor had a default prefix, "d-", cursors might be null
                if (cursors == null)
                {
                    cursors = new List <Cursor>();
                }
                // If the streams don't match the cursors then throw it out
                else if (cursors.Count != _streams.Count)
                {
                    cursors.Clear();
                }
            }

            // No cursors so we need to populate them from the list of streams
            if (cursors.Count == 0)
            {
                for (int streamIndex = 0; streamIndex < _streams.Count; streamIndex++)
                {
                    AddCursorForStream(streamIndex, cursors);
                }
            }

            _cursors = cursors;
            _trace   = traceManager["SignalR." + typeof(ScaleoutSubscription).Name];
        }
コード例 #34
0
ファイル: HostedRun.cs プロジェクト: GaneshBachhao/SignalR
        protected override IPerformanceCounter[] GetPerformanceCounters(IPerformanceCounterManager counterManager)
        {
            if (RunData.Host != "External")
            {
                return base.GetPerformanceCounters(counterManager);
            }

            return new IPerformanceCounter[0];
        }
コード例 #35
0
 public ForeverTransport(HostContext context,
                         IJsonSerializer jsonSerializer,
                         ITransportHeartBeat heartBeat,
                         IPerformanceCounterManager performanceCounterWriter)
     : base(context, jsonSerializer, heartBeat, performanceCounterWriter)
 {
     _jsonSerializer = jsonSerializer;
     _counters       = performanceCounterWriter;
 }
コード例 #36
0
 public ForeverTransport(HostContext context,
                         IJsonSerializer jsonSerializer,
                         ITransportHeartBeat heartBeat,
                         IPerformanceCounterManager performanceCounterWriter)
     : base(context, jsonSerializer, heartBeat, performanceCounterWriter)
 {
     _jsonSerializer = jsonSerializer;
     _counters = performanceCounterWriter;
 }
コード例 #37
0
ファイル: MessageBus.cs プロジェクト: eduaglz/SignalR-Server
        public MessageBus(IStringMinifier stringMinifier,
                          ILoggerFactory loggerFactory,
                          IPerformanceCounterManager performanceCounterManager,
                          IOptions<MessageBusOptions> optionsAccessor)
        {
            if (stringMinifier == null)
            {
                throw new ArgumentNullException("stringMinifier");
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException("traceManager");
            }

            if (performanceCounterManager == null)
            {
                throw new ArgumentNullException("performanceCounterManager");
            }

            if (optionsAccessor == null)
            {
                throw new ArgumentNullException("optionsAccessor");
            }

            var options = optionsAccessor.Options;

            if (options.MessageBufferSize < 0)
            {
                throw new ArgumentOutOfRangeException(Resources.Error_BufferSizeOutOfRange);
            }

            _stringMinifier = stringMinifier;
            _loggerFactory = loggerFactory;
            Counters = performanceCounterManager;
            _logger = _loggerFactory.CreateLogger<MessageBus>();
            _maxTopicsWithNoSubscriptions = options.MaxTopicsWithNoSubscriptions;

            _gcTimer = new Timer(_ => GarbageCollectTopics(), state: null, dueTime: _gcInterval, period: _gcInterval);

            _broker = new MessageBroker(Counters)
            {
                Logger = _logger
            };

            // The default message store size
            _messageStoreSize = (uint)options.MessageBufferSize;

            _topicTtl = options.TopicTTL;
            _createTopic = CreateTopic;
            _addEvent = AddEvent;
            _removeEvent = RemoveEvent;
            _disposeSubscription = o => DisposeSubscription(o);

            Topics = new TopicLookup();
        }
コード例 #38
0
        public MessageBus(IStringMinifier stringMinifier,
                          ILoggerFactory loggerFactory,
                          IPerformanceCounterManager performanceCounterManager,
                          IOptions <MessageBusOptions> optionsAccessor)
        {
            if (stringMinifier == null)
            {
                throw new ArgumentNullException("stringMinifier");
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException("traceManager");
            }

            if (performanceCounterManager == null)
            {
                throw new ArgumentNullException("performanceCounterManager");
            }

            if (optionsAccessor == null)
            {
                throw new ArgumentNullException("optionsAccessor");
            }

            var options = optionsAccessor.Value;

            if (options.MessageBufferSize < 0)
            {
                throw new ArgumentOutOfRangeException(Resources.Error_BufferSizeOutOfRange);
            }

            _stringMinifier = stringMinifier;
            _loggerFactory  = loggerFactory;
            Counters        = performanceCounterManager;
            _logger         = _loggerFactory.CreateLogger <MessageBus>();
            _maxTopicsWithNoSubscriptions = options.MaxTopicsWithNoSubscriptions;

            _gcTimer = new Timer(_ => GarbageCollectTopics(), state: null, dueTime: _gcInterval, period: _gcInterval);

            _broker = new MessageBroker(Counters)
            {
                Logger = _logger
            };

            // The default message store size
            _messageStoreSize = (uint)options.MessageBufferSize;

            _topicTtl            = options.TopicTTL;
            _createTopic         = CreateTopic;
            _addEvent            = AddEvent;
            _removeEvent         = RemoveEvent;
            _disposeSubscription = o => DisposeSubscription(o);

            Topics = new TopicLookup();
        }
コード例 #39
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="traceManager"></param>
        public MessageBus(ITraceManager traceManager, IPerformanceCounterManager performanceCounterManager)
        {
            _trace    = traceManager;
            _counters = performanceCounterManager;

            _broker = new MessageBroker(_topics, _counters)
            {
                Trace = Trace
            };
        }
コード例 #40
0
 public TestScaleoutBus(int streams,
                        IStringMinifier stringMinifier,
                        ILoggerFactory loggerFactory,
                        IPerformanceCounterManager performanceCounterManager,
                        IOptions <MessageBusOptions> optionsAccessor,
                        IOptions <ScaleoutOptions> scaleoutOptionsAccessor)
     : base(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor, scaleoutOptionsAccessor)
 {
     _streams = streams;
 }
コード例 #41
0
 public ScaleoutStreamManager(Func <int, IList <Message>, Task> send,
                              Action <int, ulong, ScaleoutMessage> receive,
                              int streamCount,
                              TraceSource trace,
                              IPerformanceCounterManager performanceCounters,
                              ScaleoutConfiguration configuration)
     : this(send, receive, streamCount, trace, performanceCounters, configuration,
            DefaultConfigurationManager.DefaultMaxScaleoutMappingsPerStream)
 {
 }
コード例 #42
0
 public LongPollingTransport(HostContext context,
                             JsonSerializer jsonSerializer,
                             ITransportHeartbeat heartbeat,
                             IPerformanceCounterManager performanceCounterManager,
                             ITraceManager traceManager,
                             IConfigurationManager configurationManager)
     : base(context, jsonSerializer, heartbeat, performanceCounterManager, traceManager)
 {
     _configurationManager = configurationManager;
 }
コード例 #43
0
ファイル: MessageBus.cs プロジェクト: Kazzje/SignalR
        /// <summary>
        /// 
        /// </summary>
        /// <param name="traceManager"></param>
        public MessageBus(ITraceManager traceManager, IPerformanceCounterManager performanceCounterManager)
        {
            _trace = traceManager;
            _counters = performanceCounterManager;

            _broker = new MessageBroker(_topics, _counters)
            {
                Trace = Trace
            };
        }
コード例 #44
0
 protected ForeverTransport(HostContext context,
                            JsonSerializer jsonSerializer,
                            ITransportHeartbeat heartbeat,
                            IPerformanceCounterManager performanceCounterWriter,
                            ITraceManager traceManager)
     : base(context, heartbeat, performanceCounterWriter, traceManager)
 {
     _jsonSerializer = jsonSerializer;
     _counters       = performanceCounterWriter;
 }
コード例 #45
0
 private TestLongPollingTransport(
     HostContext context,
     JsonSerializer json,
     ITransportHeartbeat heartBeat,
     IPerformanceCounterManager counters,
     ITraceManager traceManager,
     IConfigurationManager configuarionManager)
     : base(context, json, heartBeat, counters, traceManager, configuarionManager)
 {
 }
コード例 #46
0
 public ForeverFrameTransport(HttpContext context,
                              JsonSerializer jsonSerializer,
                              ITransportHeartbeat heartbeat,
                              IPerformanceCounterManager performanceCounterWriter,
                              IApplicationLifetime applicationLifetime,
                              ILoggerFactory loggerFactory,
                              IMemoryPool pool)
     : base(context, jsonSerializer, heartbeat, performanceCounterWriter, applicationLifetime, loggerFactory, pool)
 {
 }
コード例 #47
0
 public LongPollingTransport(HostContext context,
                             IJsonSerializer jsonSerializer,
                             ITransportHeartbeat heartbeat,
                             IPerformanceCounterManager performanceCounterManager,
                             ITraceManager traceManager)
     : base(context, heartbeat, performanceCounterManager, traceManager)
 {
     _jsonSerializer = jsonSerializer;
     _counters       = performanceCounterManager;
 }
コード例 #48
0
 protected ForeverTransport(HostContext context,
                            JsonSerializer jsonSerializer,
                            ITransportHeartbeat heartbeat,
                            IPerformanceCounterManager performanceCounterWriter,
                            ITraceManager traceManager)
     : base(context, heartbeat, performanceCounterWriter, traceManager)
 {
     _jsonSerializer = jsonSerializer;
     _counters = performanceCounterWriter;
 }
コード例 #49
0
 public LongPollingTransport(HostContext context,
                             IJsonSerializer jsonSerializer,
                             ITransportHeartbeat heartbeat,
                             IPerformanceCounterManager performanceCounterManager,
                             ITraceManager traceManager)
     : base(context, heartbeat, performanceCounterManager, traceManager)
 {
     _jsonSerializer = jsonSerializer;
     _counters = performanceCounterManager;
 }
コード例 #50
0
 public LongPollingTransport(HostContext context,
                             JsonSerializer jsonSerializer,
                             ITransportHeartbeat heartbeat,
                             IPerformanceCounterManager performanceCounterManager,
                             ITraceManager traceManager,
                             IConfigurationManager configurationManager)
     : base(context, jsonSerializer, heartbeat, performanceCounterManager, traceManager)
 {
     _configurationManager = configurationManager;
 }
コード例 #51
0
 public WebSocketTransport(HttpContext context,
                           JsonSerializer serializer,
                           ITransportHeartbeat heartbeat,
                           IPerformanceCounterManager performanceCounterManager,
                           IApplicationLifetime applicationLifetime,
                           ILoggerFactory loggerFactory,
                           IMemoryPool pool)
     : this(context, serializer, heartbeat, performanceCounterManager, applicationLifetime, loggerFactory, pool, maxIncomingMessageSize : null)
 {
 }
コード例 #52
0
 public WebSocketTransport(HttpContext context,
                           JsonSerializer serializer,
                           ITransportHeartbeat heartbeat,
                           IPerformanceCounterManager performanceCounterManager,
                           IApplicationLifetime applicationLifetime,
                           ILoggerFactory loggerFactory,
                           IMemoryPool pool)
     : this(context, serializer, heartbeat, performanceCounterManager, applicationLifetime, loggerFactory, pool, maxIncomingMessageSize: null)
 {
 }
コード例 #53
0
 private TestLongPollingTransport(
     HostContext context,
     JsonSerializer json,
     ITransportHeartbeat heartBeat,
     IPerformanceCounterManager counters,
     ITraceManager traceManager,
     IConfigurationManager configurationManager)
     : base(context, json, heartBeat, counters, traceManager, configurationManager, new MemoryPool())
 {
 }
コード例 #54
0
ファイル: MessageBus.cs プロジェクト: SaveTrees/SignalR
        public MessageBus(IStringMinifier stringMinifier,
                          ITraceManager traceManager,
                          IPerformanceCounterManager performanceCounterManager,
                          IConfigurationManager configurationManager,
                          int maxTopicsWithNoSubscriptions)
        {
            if (stringMinifier == null)
            {
                throw new ArgumentNullException("stringMinifier");
            }

            if (traceManager == null)
            {
                throw new ArgumentNullException("traceManager");
            }

            if (performanceCounterManager == null)
            {
                throw new ArgumentNullException("performanceCounterManager");
            }

            if (configurationManager == null)
            {
                throw new ArgumentNullException("configurationManager");
            }

            if (configurationManager.DefaultMessageBufferSize < 0)
            {
                throw new ArgumentOutOfRangeException(Resources.Error_BufferSizeOutOfRange);
            }

            _stringMinifier = stringMinifier;
            _traceManager = traceManager;
            Counters = performanceCounterManager;
            _trace = _traceManager["SignalR." + typeof(MessageBus).Name];
            _maxTopicsWithNoSubscriptions = maxTopicsWithNoSubscriptions;

            _gcTimer = new Timer(_ => GarbageCollectTopics(), state: null, dueTime: _gcInterval, period: _gcInterval);

            _broker = new MessageBroker(Counters)
            {
                Trace = _trace
            };

            // The default message store size
            _messageStoreSize = (uint)configurationManager.DefaultMessageBufferSize;

            _topicTtl = configurationManager.TopicTtl();
            _createTopic = CreateTopic;
            _addEvent = AddEvent;
            _removeEvent = RemoveEvent;
            _disposeSubscription = o => DisposeSubscription(o);

            Topics = new TopicLookup();
        }
 protected ScaleoutMessageBus(IStringMinifier stringMinifier,
                              ILoggerFactory loggerFactory,
                              IPerformanceCounterManager performanceCounterManager,
                              IOptions<MessageBusOptions> optionsAccessor,
                              IOptions<ScaleoutOptions> scaleoutOptionsAccessor)
     : base(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor)
 {
     _logger = loggerFactory.CreateLogger<ScaleoutMessageBus>();
     _perfCounters = performanceCounterManager;
     _streamManager = new Lazy<ScaleoutStreamManager>(() => new ScaleoutStreamManager(Send, OnReceivedCore, StreamCount, _logger, _perfCounters, scaleoutOptionsAccessor.Value));
 }
コード例 #56
0
 public ServerSentEventsTransport(HttpContext context,
                                  JsonSerializer jsonSerializer,
                                  ITransportHeartbeat heartbeat,
                                  IPerformanceCounterManager performanceCounterManager,
                                  IApplicationLifetime applicationLifetime,
                                  ILoggerFactory loggerFactory,
                                  IMemoryPool pool)
     : base(context, jsonSerializer, heartbeat, performanceCounterManager, applicationLifetime, loggerFactory, pool)
 {
     _counters = performanceCounterManager;
 }
コード例 #57
0
ファイル: WebSocketTransport.cs プロジェクト: nirmana/SignalR
 public WebSocketTransport(HostContext context,
                           JsonSerializer serializer,
                           ITransportHeartbeat heartbeat,
                           IPerformanceCounterManager performanceCounterWriter,
                           ITraceManager traceManager)
     : base(context, serializer, heartbeat, performanceCounterWriter, traceManager)
 {
     _context = context;
     _message = OnMessage;
     _closed = OnClosed;
     _error = OnError;
 }
コード例 #58
0
 protected ForeverTransport(HttpContext context,
                            JsonSerializer jsonSerializer,
                            ITransportHeartbeat heartbeat,
                            IPerformanceCounterManager performanceCounterManager,
                            IApplicationLifetime applicationLifetime,
                            ILoggerFactory loggerFactory,
                            IMemoryPool pool)
     : base(context, heartbeat, performanceCounterManager, applicationLifetime, loggerFactory, pool)
 {
     _jsonSerializer = jsonSerializer;
     _counters = performanceCounterManager;
 }
コード例 #59
0
 public LongPollingTransport(HttpContext context,
                             JsonSerializer jsonSerializer,
                             ITransportHeartbeat heartbeat,
                             IPerformanceCounterManager performanceCounterManager,
                             IApplicationLifetime applicationLifetime,
                             ILoggerFactory loggerFactory,
                             IOptions<SignalROptions> optionsAccessor,
                             IMemoryPool pool)
     : base(context, jsonSerializer, heartbeat, performanceCounterManager, applicationLifetime, loggerFactory, pool)
 {
     _pollDelay = optionsAccessor.Value.Transports.LongPolling.PollDelay;
     _counters = performanceCounterManager;
 }
コード例 #60
0
        protected ScaleoutMessageBus(IDependencyResolver resolver, ScaleoutConfiguration configuration)
            : base(resolver)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            var traceManager = resolver.Resolve<ITraceManager>();
            _trace = traceManager["SignalR." + typeof(ScaleoutMessageBus).Name];
            _perfCounters = resolver.Resolve<IPerformanceCounterManager>();
            _streamManager = new Lazy<ScaleoutStreamManager>(() => new ScaleoutStreamManager(Send, OnReceivedCore, StreamCount, _trace, _perfCounters, configuration));
        }