Beispiel #1
0
        public BackgroundTaskHost(
            IServiceProvider backgroundServices,
            IBackgroundTaskStore store,
            IBackgroundTaskSerializer serializer,
            ITypeResolver typeResolver,
            IOptionsMonitor <BackgroundTaskOptions> options,
            ISafeLogger <BackgroundTaskHost> logger)
        {
            _backgroundServices = backgroundServices;
            Store         = store;
            Serializer    = serializer;
            _typeResolver = typeResolver;
            _options      = options;
            _logger       = logger;
            options.OnChange(OnSettingsChanged);

            _schedulers = new ConcurrentDictionary <int, TaskScheduler>();
            _factories  = new ConcurrentDictionary <TaskScheduler, TaskFactory>();
            _pending    = new ConcurrentDictionary <object, HandlerHooks>();
            _cancel     = new CancellationTokenSource();

            // dispatch thread
            _background = new PushQueue <IEnumerable <BackgroundTask> >();
            _background.Attach(WithPendingTasks);
            _background.AttachBacklog(WithOverflowTasks);
            _background.AttachUndeliverable(WithFailedTasks);

            // maintenance thread
            _maintenance = new PushQueue <IEnumerable <BackgroundTask> >();
            _maintenance.Attach(WithHangingTasks);
            _maintenance.AttachBacklog(WithHangingTasks);
            _maintenance.AttachUndeliverable(WithFailedTasks);
        }
Beispiel #2
0
        public Pupindra(string connectionString)
        {
            _queue = new PushQueue <PrescencePushData>(connectionString, PushMessageType.PresenceService);

            t_ = Task.Run(async() =>
            {
                var tm = DateTime.Now;
                while (true)
                {
                    await Task.Delay(1000);
                    foreach (var st in users.Values)
                    {
                        st.dummy    = DateTime.UtcNow.Second;
                        st.version += 1;
                        if (st.tk != null)
                        {
                            _queue.Enqueue(st.tk, new PrescencePushData()
                            {
                                Dummy = st.dummy, Version = st.version, Kuku = $"Kuku {DateTime.UtcNow}"
                            });
                        }
                    }
                }
            });
        }
Beispiel #3
0
        protected void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            if (_cancel != null)
            {
                _cancel.Cancel();
                _cancel.Token.WaitHandle.WaitOne();
                _cancel.Dispose();
                _cancel = null;
            }

            _factories?.Clear();
            _schedulers?.Clear();

            _scheduler?.Dispose();
            _scheduler = null;

            _background?.Dispose();
            _background = null;

            _maintenance?.Dispose();
            _maintenance = null;
        }
        public OperationsHost(IStringLocalizer <OperationsHost> localizer, IOptionsMonitor <OperationOptions> options, ILogger <OperationsHost> logger)
        {
            _localizer = localizer;
            _options   = options;
            _logger    = logger;
            _cancel    = new CancellationTokenSource();
            _scheduler ??= new QueuedTaskScheduler(ResolveConcurrency());

            _schedulers = new ConcurrentDictionary <int, TaskScheduler>();
            _factories  = new ConcurrentDictionary <TaskScheduler, TaskFactory>();
            _cancel     = new CancellationTokenSource();

            // dispatch thread
            _background = new PushQueue <IEnumerable <Operation> >();
            //_background.Attach(WithPendingTasks);
            //_background.AttachBacklog(WithOverflowTasks);
            //_background.AttachUndeliverable(WithFailedTasks);

            // maintenance thread
            _maintenance = new PushQueue <IEnumerable <Operation> >();
            //_maintenance.Attach(WithHangingTasks);
            //_maintenance.AttachBacklog(WithHangingTasks);
            //_maintenance.AttachUndeliverable(WithFailedTasks);

            options.OnChange(OnOptionsChanged);
        }
Beispiel #5
0
 private CustomerLog()
 {
     _pushQueue = new PushQueue <DirectoryNameAndContent>()
     {
         MaxCacheCount = 100
     };
     _pushQueue.OnPushData += PushQueue_OnPushData;
     _pushQueue.StartAsync().Wait();
 }
Beispiel #6
0
            private void ILPush(QuadTuple qt)
            {
                var tplt = ",{0}";

                if (PushQueue is null)
                {
                    PushQueue = new List <string>();
                }
                if (qt.LValue.ValueType == "string")
                {
                    PushQueue.Add(string.Format(tplt, "offset " + qt.LValue.ID));
                }
                else
                {
                    PushQueue.Add(string.Format(tplt, qt.LValue.ID));
                }
            }
 public void HandleEvent(KafkaTopicEventData eventData)
 {
     PushQueue.Add(eventData);
 }
 public IHttpActionResult Enqueue(AnuntDto anunt)
 {
     PushQueue.Enqueue(anunt);
     return(Ok());
 }
Beispiel #9
0
 public static void InitQueue()
 {
     PushQueue.Init();
 }