Beispiel #1
0
 public UnhandledExceptionFilter(
     IOptions <ExceptionProcessingOptions> options,
     ILogger <UnhandledExceptionFilter> logger = null)
 {
     _options = options.Value;
     _log     = logger.Dsl();
 }
Beispiel #2
0
 public MqConsumingStarter(
     IMqConsumerHost consumerHost,
     ILogger <MqConsumingStarter> logger = null)
 {
     _consumerHost = consumerHost ?? throw new ArgumentNullException(nameof(consumerHost));
     _log          = logger?.Dsl();
 }
 /// <summary>
 /// Initializes a new instance of <see cref="DefaultMqConnectionProvider"/>
 /// </summary>
 public DefaultMqConnectionProvider(
     MqOptions options,
     ILogger <DefaultMqConnectionProvider> logger = null)
     : this(OptionToConnectionFactory(options))
 {
     _log     = logger?.Dsl();
     _options = options;
 }
Beispiel #4
0
        /// <summary>
        /// Begin DSL expression for error log-event
        /// </summary>
        public static DslExpression Error(this IDslLogger dslLogger, string message, Exception reasonException)
        {
            if (dslLogger == null)
            {
                throw new ArgumentNullException(nameof(dslLogger));
            }

            return(dslLogger.Error(message).BecauseOf(reasonException));
        }
Beispiel #5
0
        public DslLogger(IServiceProvider serviceProvider, ILogger innerLogger = null)
        {
            if (innerLogger == null)
            {
                throw new InvalidOperationException("Built-In .NET core logging required");
            }
            _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));

            _dsl = innerLogger.Dsl();
        }
Beispiel #6
0
 public DefaultInputMessageEmulator(
     IMqInitialConsumerRegistry initialConsumerRegistry,
     IServiceProvider serviceProvider,
     ILogger <DefaultInputMessageEmulator> logger = null)
 {
     _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
     _consumers       = initialConsumerRegistry
                        .GetConsumers(_serviceProvider)
                        .ToDictionary(c => c.Queue, c => c);
     _log = logger?.Dsl();
 }
Beispiel #7
0
        /// <summary>
        /// Begin DSL expression for warning log-event
        /// </summary>
        public static DslExpression Warning(this IDslLogger dslLogger, Exception reasonException)
        {
            if (dslLogger == null)
            {
                throw new ArgumentNullException(nameof(dslLogger));
            }
            if (reasonException == null)
            {
                throw new ArgumentNullException(nameof(reasonException));
            }

            return(dslLogger.Warning(reasonException.Message).BecauseOf(reasonException));
        }
        public CirclePerformer(
            ITaskLogic logic,
            IOptions <TaskOptions> options,
            ITaskStatusService statusService = null,
            ILogger <CirclePerformer> logger = null)
        {
            _logic         = logic;
            _statusService = statusService;
            _log           = logger.Dsl();

            if (options.Value == null || options.Value.IdlePeriod == default)
            {
                _period = TimeSpan.FromSeconds(1);
            }
            else
            {
                _period = options.Value.IdlePeriod;
            }
        }
Beispiel #9
0
        public MqConsumerHost(IMqChannelProvider channelProvider,
                              IMqInitialConsumerRegistry initialConsumerRegistry,
                              IServiceProvider serviceProvider,
                              IMqStatusService mqStatusService,
                              IEnabledIndicatorService enabledIndicatorService = null,
                              ILogger <MqConsumerHost> logger = null)
        {
            _logger = logger?.Dsl();
            var messageProcessor = new QueueMessageProcessor(mqStatusService, serviceProvider, _runConsumers)
            {
                Logger = _logger
            };

            _channelMessageReceivingController = new ChannelMessageReceivingController(messageProcessor);
            _channelCallbackExceptionLogger    = new ChannelCallbackExceptionLogger(logger);
            _channelProvider         = channelProvider ?? throw new ArgumentNullException(nameof(channelProvider));
            _initialConsumerRegistry = initialConsumerRegistry ?? throw new ArgumentNullException(nameof(initialConsumerRegistry));
            _serviceProvider         = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
            _mqStatusService         = mqStatusService;
            _enabledIndicatorService = enabledIndicatorService;
        }
Beispiel #10
0
 public KickTaskJob(ITaskKickerService taskKickerService, ILogger <KickTaskJob> logger)
 {
     _taskKickerService = taskKickerService;
     _logger            = logger.Dsl();
 }
Beispiel #11
0
        /// <inheritdoc />
        public override async Task Consume(IConsumingContext consumingContext)
        {
            _lastMsgTime = DateTime.Now;

            var consumedMessage = consumingContext.GetMessage <TMsgPayload>();

            var logger = consumingContext.GetLogger <MqBatchConsumer <TMsgPayload, TLogic> >();

            _lastLogger           = logger;
            _lastLogic            = _singletonLogic ?? consumingContext.CreateLogic <TLogic>();
            _lastConsumingContext = consumingContext;

            logger.Debug("Input mq message")
            .AndFactIs("queue", Queue)
            .AndFactIs("msg-id", consumedMessage.MessageId)
            .AndLabel("batch-consumer")
            .Write();

            _messages.Add(consumedMessage);

            if (_messages.Count >= BatchSize)
            {
                logger.Debug("Perform consuming")
                .AndFactIs("queue", Queue)
                .AndFactIs("msg-count", _messages.Count)
                .AndLabel("sync-mq-batch-processing")
                .Write();

                await PerformConsumingAsync();
            }

            if (_monitorTask != null)
            {
                ExceptionDto exDto = null;

                if (_monitorTask.Exception != null)
                {
                    exDto = ExceptionDto.Create(_monitorTask.Exception);
                }

                logger.Debug("Monitor task state")
                .AndFactIs("Status", _monitorTask.Status)
                .AndFactIs("IsCompleted", _monitorTask.IsCompleted)
                .AndFactIs("IsCompletedSuccessfully", _monitorTask.IsCompletedSuccessfully)
                .AndFactIs("IsFaulted", _monitorTask.IsFaulted)
                .AndFactIs("IsCanceled", _monitorTask.IsCanceled)
                .AndFactIs("Exception", exDto ?? (object)"no-exception")
                .Write();
            }

            _monitorTask ??= Task.Run(Async);

            //try
            //{
            //    logger.Debug("Monitor task state")
            //        .AndFactIs("task", _monitorTask)
            //        .Write();
            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine(e);
            //    throw;
            //}
        }
 public ChannelCallbackExceptionLogger(ILogger logger)
 {
     _logger = logger.Dsl();
 }