示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HeartBeatWorkerFactory" /> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="sendHeartBeat">The send heart beat module.</param>
        /// <param name="scheduler">The scheduler.</param>
        /// <param name="logFactory">The log factory.</param>
        /// <param name="heartBeatNotificationFactory">The heart beat notification factory.</param>
        public HeartBeatWorkerFactory(IHeartBeatConfiguration configuration,
                                      ISendHeartBeat sendHeartBeat,
                                      IHeartBeatScheduler scheduler,
                                      ILogFactory logFactory,
                                      IWorkerHeartBeatNotificationFactory heartBeatNotificationFactory)
        {
            Guard.NotNull(() => configuration, configuration);
            Guard.NotNull(() => sendHeartBeat, sendHeartBeat);
            Guard.NotNull(() => scheduler, scheduler);
            Guard.NotNull(() => logFactory, logFactory);
            Guard.NotNull(() => heartBeatNotificationFactory, heartBeatNotificationFactory);

            _configuration = configuration;
            _sendHeartBeat = sendHeartBeat;
            _scheduler     = scheduler;
            _logFactory    = logFactory;
            _heartBeatNotificationFactory = heartBeatNotificationFactory;
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HeartBeatWorker" /> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="context">The context.</param>
        /// <param name="sendHeartBeat">The send heart beat.</param>
        /// <param name="scheduler">The scheduler.</param>
        /// <param name="log">The log.</param>
        /// <param name="heartBeatNotificationFactory">The heart beat notification factory.</param>
        public HeartBeatWorker(IHeartBeatConfiguration configuration,
                               IMessageContext context,
                               ISendHeartBeat sendHeartBeat,
                               IHeartBeatScheduler scheduler,
                               ILogFactory log,
                               IWorkerHeartBeatNotificationFactory heartBeatNotificationFactory)
        {
            Guard.NotNull(() => configuration, configuration);
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => sendHeartBeat, sendHeartBeat);
            Guard.NotNull(() => scheduler, scheduler);
            Guard.NotNull(() => log, log);
            Guard.NotNull(() => heartBeatNotificationFactory, heartBeatNotificationFactory);

            _context       = context;
            _checkTime     = configuration.UpdateTime;
            _sendHeartbeat = sendHeartBeat;
            _scheduler     = scheduler;
            _logger        = log.Create();

            _cancel = new CancellationTokenSource();
            context.WorkerNotification.HeartBeat = heartBeatNotificationFactory.Create(_cancel.Token);
        }