//--- Constructors ---

        /// <summary>
        /// Create a new dispatcher.
        /// </summary>
        /// <param name="config">Configuration instance injected from pub sub service.</param>
        public Dispatcher(DispatcherConfig config)
        {
            _owner = config.ServiceUri.AsServerUri();
            _serviceKeySetCookie = config.ServiceAccessCookie;
            _combinedSet         = new PubSubSubscriptionSet(_owner, 0, _serviceKeySetCookie);
            _dispatchQueue       = new ProcessingQueue <DispatcherEvent>(DispatchFromQueue, 10);
        }
Esempio n. 2
0
 //--- Constructors ---
 public DekiDispatcher(DispatcherConfig config, IPubSubDispatchQueueRepository repository)
     : base(config, repository) {
     _authtoken = config.ServiceConfig["authtoken"].AsText;
     var dekiUri = config.ServiceConfig["uri.deki"].AsUri;
     if(config.ServiceCookies != null) {
         _cookieJar.Update(config.ServiceCookies.Fetch(dekiUri), null);
     }
     _deki = Plug.New(dekiUri).WithCookieJar(_cookieJar);
 }
Esempio n. 3
0
 //--- Constructors ---
 /// <summary>
 /// Create a new dispatcher.
 /// </summary>
 /// <param name="config">Configuration instance injected from pub sub service.</param>
 public Dispatcher(DispatcherConfig config)
 {
     _owner = config.ServiceUri.AsServerUri();
     _serviceKeySetCookie = config.ServiceAccessCookie;
     _combinedSet = new PubSubSubscriptionSet(_owner, 0, _serviceKeySetCookie);
     _dispatchQueue = new ProcessingQueue<DispatcherEvent>(DispatchFromQueue, 10);
 }
Esempio n. 4
0
        //--- Constructors ---
        /// <summary>
        /// Create a new dispatcher.
        /// </summary>
        /// <param name="config">Configuration instance injected from pub sub service.</param>
        /// <param name="queueRepository">Factory for dispatch queues used by persisted (i.e. expiring) subscriptions</param>
        public Dispatcher(DispatcherConfig config, IPubSubDispatchQueueRepository queueRepository)
        {
            _queueRepository = queueRepository;
            _owner = config.ServiceUri.AsServerUri();
            _serviceKeySetCookie = config.ServiceAccessCookie;
            _combinedSet = new PubSubSubscriptionSet(_owner, 0, _serviceKeySetCookie);
            _dispatchQueue = new ProcessingQueue<DispatcherEvent>(DispatchFromQueue, 10);
            _defaultQueue = new ImmediatePubSubDispatchQueue(TryDispatchItem);
            var pubSubSubscriptionSets = queueRepository.GetUninitializedSets();

            // Note (arnec): only invoking lock here, so that RegisterSet and Update don't do it over and over
            lock(_subscriptionsByOwner) {
                foreach(var set in pubSubSubscriptionSets) {
                    RegisterSet(set, true);
                }
                Update();
            }
            queueRepository.InitializeRepository(TryDispatchItem);
        }