Example #1
0
        //TODO:FOUNDATION:SHOULD: Move to Codeable Libraries
        private async Task <T> ExecuteFunctionAsyncInternal <T>(string name, Func <Task <T> > method, Action <Exception> onError = null, bool forceThrow = false)
        {
            try
            {
                T result = await method();

                return(result);
            }
            catch (Exception ex)
            {
                base.IFoundation.LogError(ex, name);
                bool             rethrow           = false;
                Exception        replacedException = null;
                bool             expectsRethrow    = false;
                IHandleException exceptionHandler  = this.IHandleExceptionProvider.CreateHandler();
                if (exceptionHandler != null)
                {
                    if (exceptionHandler.HandleException(ex, out expectsRethrow, out replacedException))
                    {
                        rethrow = expectsRethrow;
                        if (replacedException != null)
                        {
                            throw replacedException;
                        }
                    }
                }

                if (forceThrow || rethrow)
                {
                    throw;
                }
                return(default(T));
            }
        }
Example #2
0
 public Producer(
     Uri serviceUrl,
     ProducerOptions <TMessage> options,
     ProcessManager processManager,
     IHandleException exceptionHandler,
     IConnectionPool connectionPool,
     ICompressorFactory?compressorFactory)
 {
     _operationName = $"{options.Topic} send";
     _tags          = new KeyValuePair <string, object?>[]
     {
         new KeyValuePair <string, object?>("messaging.destination", options.Topic),
         new KeyValuePair <string, object?>("messaging.destination_kind", "topic"),
         new KeyValuePair <string, object?>("messaging.system", "pulsar"),
         new KeyValuePair <string, object?>("messaging.url", serviceUrl),
     };
     _sequenceId        = new SequenceId(options.InitialSequenceId);
     _state             = new StateManager <ProducerState>(ProducerState.Disconnected, ProducerState.Closed, ProducerState.Faulted);
     ServiceUrl         = serviceUrl;
     Topic              = options.Topic;
     _isDisposed        = 0;
     _options           = options;
     _exceptionHandler  = exceptionHandler;
     _connectionPool    = connectionPool;
     _compressorFactory = compressorFactory;
     _processManager    = processManager;
     _messageRouter     = options.MessageRouter;
     _cts       = new CancellationTokenSource();
     _executor  = new Executor(Guid.Empty, this, _exceptionHandler);
     _producers = new ConcurrentDictionary <int, SubProducer <TMessage> >();
     _          = Setup();
 }
Example #3
0
 internal PulsarClient(IConnectionPool connectionPool, ProcessManager processManager, IHandleException exceptionHandler)
 {
     _connectionPool   = connectionPool;
     _processManager   = processManager;
     _exceptionHandler = exceptionHandler;
     _isDisposed       = 0;
     DotPulsarEventSource.Log.ClientCreated();
 }
Example #4
0
 public Producer(
     Uri serviceUrl,
     ProducerOptions <TMessage> options,
     ProcessManager processManager,
     IHandleException exceptionHandler,
     IConnectionPool connectionPool,
     ICompressorFactory?compressorFactory)
 {
     _state             = new StateManager <ProducerState>(ProducerState.Disconnected, ProducerState.Closed, ProducerState.Faulted);
     ServiceUrl         = serviceUrl;
     Topic              = options.Topic;
     _isDisposed        = 0;
     _options           = options;
     _exceptionHandler  = exceptionHandler;
     _connectionPool    = connectionPool;
     _compressorFactory = compressorFactory;
     _processManager    = processManager;
     _messageRouter     = options.MessageRouter;
     _cts       = new CancellationTokenSource();
     _executor  = new Executor(Guid.Empty, this, _exceptionHandler);
     _producers = new ConcurrentDictionary <int, IProducer <TMessage> >();
     _          = Setup();
 }
Example #5
0
 public Executor(Guid correlationId, IRegisterEvent eventRegister, IHandleException exceptionHandler)
 {
     _correlationId    = correlationId;
     _eventRegister    = eventRegister;
     _exceptionHandler = exceptionHandler;
 }
Example #6
0
 public static PulsarClient CreatePulsarClient(IConnectionPool connectionPool, ProcessManager processManager, IHandleException exceptionHandler, Uri serviceUrl)
 => new(connectionPool, processManager, exceptionHandler, serviceUrl);
Example #7
0
 public IPulsarClientBuilder ExceptionHandler(IHandleException exceptionHandler)
 {
     _exceptionHandlers.Add(exceptionHandler);
     return(this);
 }
 public XunitExceptionHandler(ITestOutputHelper output, IHandleException exceptionHandler)
 {
     _output           = output;
     _exceptionHandler = exceptionHandler;
 }
 public void AddExceptionHandler(IHandleException handler)
 {
     ExceptionHandler = handler;
 }