Ejemplo n.º 1
0
 public static ConsumerPipelineContext CreateSubstitute(
     IRawInboundEnvelope?envelope     = null,
     IServiceProvider?serviceProvider = null,
     IConsumerTransactionManager?transactionManager = null,
     IConsumer?consumer           = null,
     ISequenceStore?sequenceStore = null,
     IConsumerEndpoint?endpoint   = null) =>
Ejemplo n.º 2
0
 public static void LogConsumerFatalError(
     this ISilverbackLogger logger,
     IConsumer?consumer,
     Exception exception) =>
 ConsumerFatalError(
     logger.InnerLogger,
     consumer?.Id ?? "?",
     consumer?.Endpoint.DisplayName ?? "?",
     exception);
Ejemplo n.º 3
0
        public static async Task ExecuteAndTraceConsumerActionAsync(
            this ISilverbackLogger logger,
            IConsumer?consumer,
            Func <Task> action,
            string enterMessage,
            string successMessage,
            string errorMessage,
            Func <object?[]>?argumentsProvider = null)
        {
            if (!logger.IsEnabled(IntegrationLogEvents.LowLevelTracing))
            {
                await action.Invoke().ConfigureAwait(false);

                return;
            }

            var args = new List <object?>(argumentsProvider?.Invoke() ?? Array.Empty <object>());

            args.Add(consumer?.Id ?? string.Empty);
            args.Add(consumer?.Endpoint.DisplayName ?? string.Empty);

            logger.InnerLogger.Log(
                IntegrationLogEvents.LowLevelTracing.Level,
                IntegrationLogEvents.LowLevelTracing.EventId,
                enterMessage + GetConsumerMessageDataString(),
                args.ToArray());

            try
            {
                await action.Invoke().ConfigureAwait(false);

                logger.InnerLogger.Log(
                    IntegrationLogEvents.LowLevelTracing.Level,
                    IntegrationLogEvents.LowLevelTracing.EventId,
                    successMessage + GetConsumerMessageDataString(),
                    args.ToArray());
            }
            catch (Exception ex)
            {
                logger.InnerLogger.Log(
                    IntegrationLogEvents.LowLevelTracing.Level,
                    IntegrationLogEvents.LowLevelTracing.EventId,
                    ex,
                    errorMessage + GetConsumerMessageDataString(),
                    args.ToArray());

                throw;
            }
        }
Ejemplo n.º 4
0
 public static Task ExecuteAndTraceConsumerActionAsync(
     this ISilverbackLogger logger,
     IConsumer?consumer,
     Func <Task> action,
     string enterMessage,
     string exitMessage,
     Func <object?[]>?argumentsProvider = null) =>
 ExecuteAndTraceConsumerActionAsync(
     logger,
     consumer,
     action,
     enterMessage,
     exitMessage,
     exitMessage,
     argumentsProvider);
Ejemplo n.º 5
0
 public static ConsumerPipelineContext CreateSubstitute(
     IRawInboundEnvelope?envelope     = null,
     IServiceProvider?serviceProvider = null,
     IConsumerTransactionManager?transactionManager = null,
     IConsumer?consumer           = null,
     ISequenceStore?sequenceStore = null,
     IConsumerEndpoint?endpoint   = null) =>
 new ConsumerPipelineContext(
     envelope ?? new RawInboundEnvelope(
         Stream.Null,
         Array.Empty <MessageHeader>(),
         endpoint ?? new TestConsumerEndpoint("test"),
         endpoint?.Name ?? "test",
         new TestOffset()),
     consumer ?? Substitute.For <IConsumer>(),
     sequenceStore ?? Substitute.For <ISequenceStore>(),
     serviceProvider ?? GetServiceProvider())
 {
     TransactionManager = transactionManager ?? Substitute.For <IConsumerTransactionManager>()
 };
Ejemplo n.º 6
0
        public static void LogConsumerLowLevelTrace(
            this ISilverbackLogger logger,
            IConsumer?consumer,
            string message,
            Func <object?[]>?argumentsProvider = null)
        {
            if (!logger.IsEnabled(IntegrationLogEvents.LowLevelTracing))
            {
                return;
            }

            var args = new List <object?>(argumentsProvider?.Invoke() ?? Array.Empty <object>());

            args.Add(consumer?.Id ?? string.Empty);
            args.Add(consumer?.Endpoint.DisplayName ?? string.Empty);

            logger.InnerLogger.Log(
                IntegrationLogEvents.LowLevelTracing.Level,
                IntegrationLogEvents.LowLevelTracing.EventId,
                message + GetConsumerMessageDataString(),
                args.ToArray());
        }