//--- Construtors
 public MemoryPubSubDispatchQueue(string location, TaskTimerFactory taskTimerFactory, TimeSpan retryTime, Func<DispatchItem, Result<bool>> handler)
 {
     if(string.IsNullOrEmpty(location)) {
         throw new ArgumentNullException("location");
     }
     if(taskTimerFactory == null) {
         throw new ArgumentNullException("taskTimerFactory");
     }
     if(handler == null) {
         throw new ArgumentNullException("handler");
     }
     _location = location;
     _retryTime = retryTime;
     _queueTimer = taskTimerFactory.New(RetryDequeue, null);
     _dequeueHandler = handler;
 }
 //--- Construtors
 public PersistentPubSubDispatchQueue(string queuePath, TaskTimerFactory taskTimerFactory, TimeSpan retryTime, Func<DispatchItem, Result<bool>> handler)
 {
     if(string.IsNullOrEmpty(queuePath)) {
         throw new ArgumentNullException("location");
     }
     if(taskTimerFactory == null) {
         throw new ArgumentNullException("taskTimerFactory");
     }
     if(handler == null) {
         throw new ArgumentNullException("handler");
     }
     _queuePath = queuePath;
     _retryTime = retryTime;
     _queueTimer = taskTimerFactory.New(RetryDequeue, null);
     _queue = new TransactionalQueue<DispatchItem>(new MultiFileQueueStream(queuePath), new DispatchItemSerializer()) {
         DefaultCommitTimeout = TimeSpan.MaxValue
     };
     _dequeueHandler = handler;
     Kick();
 }
Beispiel #3
0
 //--- Constructors ---
 public Listener(string queuename, Action<AwsSqsMessage> callback, IAwsSqsClient client, TaskTimerFactory timerFactory, TimeSpan interval)
 {
     _queuename = queuename;
     _callback = callback;
     _client = client;
     _cache = new ExpiringHashSet<string>(timerFactory);
     _cacheTimer = ((interval.TotalSeconds * 2 < 60) ? 60 : interval.TotalSeconds * 2 + 1).Seconds();
     _pollTimer = timerFactory.New(tt => Coroutine.Invoke(PollSqs, new Result()).WhenDone(r => _pollTimer.Change(interval, TaskEnv.None)), null);
     _pollTimer.Change(0.Seconds(), TaskEnv.None);
 }
Beispiel #4
0
        //--- Constructors ---
        public SearchInstanceData(string indexPath, Analyzer analyzer, UpdateDelayQueue queue, TimeSpan commitInterval, TaskTimerFactory taskTimerFactory) {
            _analyzer = analyzer;
            _directory = FSDirectory.GetDirectory(indexPath);

            // Note (arnec): Needed with SimpleFSLock, since a hard shutdown will have left the lock dangling
            IndexWriter.Unlock(_directory);
            try {
                _writer = new IndexWriter(_directory, _analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
            } catch(CorruptIndexException e) {
                _log.WarnFormat("The Search index at {0} is corrupt. You must repair or delete it before restarting the service. If you delete it, you must rebuild your index after service restart.", indexPath);
                if(e.Message.StartsWith("Unknown format version")) {
                    _log.Warn("The index is considered corrupt because it's an unknown version. Did you accidentally downgrade your install?");
                }
                throw;
            }
            _reader = IndexReader.Open(_directory);
            _searcher = new IndexSearcher(_reader);
            _queue = queue;
            _commitInterval = commitInterval;
            _taskTimerFactory = taskTimerFactory;
            if(_commitInterval != TimeSpan.Zero) {
                _commitTimer = _taskTimerFactory.New(_commitInterval, Commit, null, TaskEnv.None);
            }
        }