Esempio n. 1
0
 public KafkaOptions(params Uri[] kafkaServerUri)
 {
     KafkaServerUri    = kafkaServerUri.ToList();
     PartitionSelector = new DefaultPartitionSelector();
     Log = new DefaultTraceLog();
     KafkaConnectionFactory = new DefaultKafkaConnectionFactory();
     ResponseTimeoutMs      = TimeSpan.FromMilliseconds(DefaultResponseTimeout);
     CacheExpiration        = TimeSpan.FromMilliseconds(DefaultCacheExpirationTimeoutMS);
     RefreshMetadataTimeout = TimeSpan.FromMilliseconds(DefaultRefreshMetadataTimeout);
     MaxRetry = DefaultMaxRetry;
     StatisticsTrackerOptions = new StatisticsTrackerOptions();
 }
Esempio n. 2
0
        /// <summary>
        /// Construct socket and open connection to a specified server.
        /// </summary>
        /// <param name="log">Logging facility for verbose messaging of actions.</param>
        /// <param name="endpoint">The IP endpoint to connect to.</param>
        /// <param name="maximumReconnectionTimeout">The maximum time to wait when backing off on reconnection attempts.</param>
        public KafkaTcpSocket(IKafkaLog log, KafkaEndpoint endpoint, int maxRetry, TimeSpan? maximumReconnectionTimeout = null, StatisticsTrackerOptions statisticsTrackerOptions = null)
        {
            _log = log;
            _endpoint = endpoint;
            _maximumReconnectionTimeout = maximumReconnectionTimeout ?? TimeSpan.FromMinutes(MaxReconnectionTimeoutMinutes);
            _maxRetry = maxRetry;
            _statisticsTrackerOptions = statisticsTrackerOptions;
            _sendTaskQueue = new AsyncCollection<SocketPayloadSendTask>();
            _readTaskQueue = new AsyncCollection<SocketPayloadReadTask>();

            //dedicate a long running task to the read/write operations
            _socketTask = Task.Run(async () => { await DedicatedSocketTask(); });

            _disposeTask = _disposeToken.Token.CreateTask();
            _disposeRegistration = _disposeToken.Token.Register(() =>
            {
                _sendTaskQueue.CompleteAdding();
                _readTaskQueue.CompleteAdding();
            });
        }
Esempio n. 3
0
 public KafkaOptions(params Uri[] kafkaServerUri)
 {
     KafkaServerUri = kafkaServerUri.ToList();
     PartitionSelector = new DefaultPartitionSelector();
     Log = new DefaultTraceLog();
     KafkaConnectionFactory = new DefaultKafkaConnectionFactory();
     ResponseTimeoutMs = TimeSpan.FromMilliseconds(DefaultResponseTimeout);
     CacheExpiration = TimeSpan.FromMilliseconds(DefaultCacheExpirationTimeoutMS);
     RefreshMetadataTimeout = TimeSpan.FromMilliseconds(DefaultRefreshMetadataTimeout);
     MaxRetry = DefaultMaxRetry;
     StatisticsTrackerOptions = new StatisticsTrackerOptions();
 }