/// <summary> /// Creates a logger based on a type. /// </summary> /// <typeparam name="T">Type that will be used to determine the logger name</typeparam> /// <returns>Logger</returns> public static ILogger Create <T>() { if (HasFactory == false) { throw new InvalidOperationException($"Initialize the log factory before using it by calling {nameof(LogFactory)}.{nameof(Initialize)}({nameof(ILogFactory)} logFactory)"); } return(_factory.Create <T>()); }
public HttpServer(ILogFactory logFactory, IServiceLocator locator) { Logger = logFactory.Create("Http server"); Listener = new HttpListener(); Listener.IgnoreWriteExceptions = true; foreach (string key in ConfigurationManager.AppSettings.Keys) { if (key.StartsWith("HttpAddress", StringComparison.InvariantCultureIgnoreCase)) { Listener.Prefixes.Add(ConfigurationManager.AppSettings[key]); } } if (Listener.Prefixes.Count == 0) { Listener.Prefixes.Add("http://*:80/"); Listener.Prefixes.Add("https://*:443/"); } Routes = new Routes(locator); var customAuth = ConfigurationManager.AppSettings["CustomAuth"]; if (!string.IsNullOrEmpty(customAuth)) { var authType = Type.GetType(customAuth); if (!typeof(HttpAuth).IsAssignableFrom(authType)) { throw new ConfigurationErrorsException("Custom auth does not inherit from HttpAuth. Please inherit from " + typeof(HttpAuth).FullName); } Authentication = locator.Resolve <HttpAuth>(authType); } else { Authentication = locator.Resolve <HttpAuth>(); } }
/// <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="threadPool">The thread pool.</param> /// <param name="log">The log.</param> /// <param name="heartBeatNotificationFactory">The heart beat notification factory.</param> public HeartBeatWorker(IHeartBeatConfiguration configuration, IMessageContext context, ISendHeartBeat sendHeartBeat, IHeartBeatThreadPool threadPool, ILogFactory log, IWorkerHeartBeatNotificationFactory heartBeatNotificationFactory) { Guard.NotNull(() => configuration, configuration); Guard.NotNull(() => context, context); Guard.NotNull(() => sendHeartBeat, sendHeartBeat); Guard.NotNull(() => threadPool, threadPool); Guard.NotNull(() => log, log); Guard.NotNull(() => heartBeatNotificationFactory, heartBeatNotificationFactory); _context = context; _checkTimespan = configuration.CheckTime; _sendHeartbeat = sendHeartBeat; _smartThreadPool = threadPool; _logger = log.Create(); _runningLock = new ReaderWriterLockSlim(); _stoppedLock = new ReaderWriterLockSlim(); _cancel = new CancellationTokenSource(); context.WorkerNotification.HeartBeat = heartBeatNotificationFactory.Create(_cancel.Token); }
public HttpServer(ILogFactory logFactory, IServiceLocator locator) { Logger = logFactory.Create("Http server"); Listener = new HttpListener(); Listener.IgnoreWriteExceptions = true; foreach (string key in ConfigurationManager.AppSettings.Keys) { if (key.StartsWith("HttpAddress", StringComparison.InvariantCultureIgnoreCase)) Listener.Prefixes.Add(ConfigurationManager.AppSettings[key]); } if (Listener.Prefixes.Count == 0) { Listener.Prefixes.Add("http://*:80/"); Listener.Prefixes.Add("https://*:443/"); } Routes = new Routes(locator); var customAuth = ConfigurationManager.AppSettings["CustomAuth"]; if (!string.IsNullOrEmpty(customAuth)) { var authType = Type.GetType(customAuth); if (!typeof(HttpAuth).IsAssignableFrom(authType)) throw new ConfigurationErrorsException("Custom auth does not inherit from HttpAuth. Please inherit from " + typeof(HttpAuth).FullName); Authentication = locator.Resolve<HttpAuth>(authType); } else Authentication = locator.Resolve<HttpAuth>(); }
public ISetting <T> Create <T>(IConverter <T> converter, string key) { //TODO: Cache stored setting and retrive if required elsewhere var setting = new Setting <T>(_logFactory.Create <T>(), _settingsStore, converter, key); return(setting); }
public FindExpiredRecordsToDeleteQueryHandlerErrorDecorator( IQueryHandler <FindExpiredMessagesToDeleteQuery, IEnumerable <long> > decorated, ILogFactory logger) { _decorated = decorated; _logger = logger.Create("FindExpiredRecordsToDeleteQueryHandler"); }
/// <summary> /// Initializes a new instance of the <see cref="MessageProcessing"/> class. /// </summary> /// <param name="receiveMessages">The receive messages.</param> /// <param name="messageContextFactory">The message context factory.</param> /// <param name="queueWaitFactory">The queue wait factory.</param> /// <param name="log">The log.</param> /// <param name="processMessage">The process message.</param> /// <param name="receivePoisonMessage">The receive poison message.</param> /// <param name="rollbackMessage">rolls back a message when an exception occurs</param> public MessageProcessing( IReceiveMessagesFactory receiveMessages, IMessageContextFactory messageContextFactory, IQueueWaitFactory queueWaitFactory, ILogFactory log, ProcessMessage processMessage, IReceivePoisonMessage receivePoisonMessage, IRollbackMessage rollbackMessage) { Guard.NotNull(() => receiveMessages, receiveMessages); Guard.NotNull(() => messageContextFactory, messageContextFactory); Guard.NotNull(() => queueWaitFactory, queueWaitFactory); Guard.NotNull(() => log, log); Guard.NotNull(() => processMessage, processMessage); Guard.NotNull(() => receivePoisonMessage, receivePoisonMessage); Guard.NotNull(() => rollbackMessage, rollbackMessage); _receiveMessages = receiveMessages.Create(); _messageContextFactory = messageContextFactory; _log = log.Create(); _processMessage = processMessage; _receivePoisonMessage = receivePoisonMessage; _rollbackMessage = rollbackMessage; _noMessageToProcessBackOffHelper = new Lazy <IQueueWait>(queueWaitFactory.CreateQueueDelay); _seriousExceptionProcessBackOffHelper = new Lazy <IQueueWait>(queueWaitFactory.CreateFatalErrorDelay); }
/// <summary> /// Initializes a new instance of the <see cref="BaseQueue" /> class. /// </summary> /// <param name="log">The log.</param> protected BaseQueue(ILogFactory log) { Guard.NotNull(() => log, log); Log = log.Create(); _startedLocker = new ReaderWriterLockSlim(); _shouldWorkLocker = new ReaderWriterLockSlim(); }
/// <summary> /// Initializes a new instance of the <see cref="MessageExceptionHandler"/> class. /// </summary> /// <param name="transportErrorHandler">The transport error handler.</param> /// <param name="log">The log.</param> public MessageExceptionHandler(IReceiveMessagesError transportErrorHandler, ILogFactory log) { Guard.NotNull(() => transportErrorHandler, transportErrorHandler); Guard.NotNull(() => log, log); _transportErrorHandler = transportErrorHandler; _log = log.Create(); }
/// <summary> /// Initializes a new instance of the <see cref="MessageExceptionHandler"/> class. /// </summary> /// <param name="transportErrorHandler">The transport error handler.</param> /// <param name="log">The log.</param> public MessageExceptionHandler(IReceiveMessagesError transportErrorHandler, ILogFactory log) { Guard.NotNull(() => transportErrorHandler, transportErrorHandler); Guard.NotNull(() => log, log); _transportErrorHandler = transportErrorHandler; _log = log.Create(); }
public Session( IApplication app, IMessageStoreFactory storeFactory, SessionID sessID, DataDictionaryProvider dataDictProvider, SessionSchedule sessionSchedule, int heartBtInt, ILogFactory logFactory, IMessageFactory msgFactory, string senderDefaultApplVerID) { this.Application = app; this.SessionID = sessID; this.DataDictionaryProvider = new DataDictionaryProvider(dataDictProvider); this.schedule_ = sessionSchedule; this.msgFactory_ = msgFactory; this.SenderDefaultApplVerID = senderDefaultApplVerID; this.SessionDataDictionary = this.DataDictionaryProvider.GetSessionDataDictionary(this.SessionID.BeginString); if (this.SessionID.IsFIXT) this.ApplicationDataDictionary = this.DataDictionaryProvider.GetApplicationDataDictionary(this.SenderDefaultApplVerID); else this.ApplicationDataDictionary = this.SessionDataDictionary; ILog log; if (null != logFactory) log = logFactory.Create(sessID); else log = new NullLog(); state_ = new SessionState(log, heartBtInt) { MessageStore = storeFactory.Create(sessID) }; // Configuration defaults. // Will be overridden by the SessionFactory with values in the user's configuration. this.PersistMessages = true; this.ResetOnDisconnect = false; this.SendRedundantResendRequests = false; this.ValidateLengthAndChecksum = true; this.CheckCompID = true; this.MillisecondsInTimeStamp = true; this.EnableLastMsgSeqNumProcessed = false; this.MaxMessagesInResendRequest = 0; this.SendLogoutBeforeTimeoutDisconnect = false; this.IgnorePossDupResendRequests = false; this.RequiresOrigSendingTime = true; this.CheckLatency = true; this.MaxLatency = 120; if (!IsSessionTime) Reset("Out of SessionTime (Session construction)"); else if (IsNewSession) Reset("New session"); lock (sessions_) { sessions_[this.SessionID] = this; } this.Application.OnCreate(this.SessionID); this.Log.OnEvent("Created session"); }
/// <summary> /// Initializes a new instance of the <see cref="ReceiveMessageQueryDecorator" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="handler">The handler.</param> public DelayedProcessingActionDecorator(ILogFactory log, IDelayedProcessingAction handler) { Guard.NotNull(() => log, log); Guard.NotNull(() => handler, handler); _log = log.Create(); _handler = handler; }
/// <summary> /// Initializes a new instance of the <see cref="Log{TSource}"/> class /// with the specified log factory. /// </summary> /// <param name="logFactory"> /// A factory used to provide a configured <see cref="ILog"/> /// implementation. /// </param> public Log(ILogFactory logFactory) { if (logFactory == null) { throw new ArgumentNullException(nameof(logFactory)); } log = logFactory.Create <TSource>(); }
public static ILog Create(Type declaringType) { if (declaringType == null) { throw new ArgumentNullException("The argument cannot be null", nameof(declaringType)); } if (factory == null) { try { factory = Factory.Get <ILogFactory>(); factory.Initialize(); } catch { } } return(factory == null ? new WrapLog(declaringType) : factory.Create(declaringType)); }
/// <summary> /// Initializes a new instance of the <see cref="ReceiveMessageQueryDecorator" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="handler">The handler.</param> public ReceiveMessageQueryDecorator(ILogFactory log, IQueryHandler <ReceiveMessageQuery, RedisMessage> handler) { Guard.NotNull(() => log, log); Guard.NotNull(() => handler, handler); _log = log.Create(); _handler = handler; }
/// <summary> /// Initializes a new instance of the <see cref="FindRecordsToResetByHeartBeatErrorDecorator"/> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="decorated">The decorated.</param> public FindRecordsToResetByHeartBeatErrorDecorator(ILogFactory logger, IQueryHandler <FindMessagesToResetByHeartBeatQuery, IEnumerable <MessageToReset> > decorated) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => logger, logger); _logger = logger.Create("FindRecordsToResetByHeartBeat"); _decorated = decorated; }
public OwinRequestContext( IOwinContext owinContext, ILogFactory logFactory) { _log = logFactory.Create(this); _incoming = new IncommingMessageWrapper(owinContext); _outgoing = new OutgoingMessageWrapper(owinContext); _environment = owinContext.Environment; }
/// <summary> /// Initializes a new instance of the <see cref="BaseTime" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="configuration">The configuration.</param> protected BaseTime(ILogFactory log, BaseTimeConfiguration configuration) { Guard.NotNull(() => log, log); Guard.NotNull(() => configuration, configuration); Configuration = configuration; Log = log.Create(); }
/// <summary> /// Initializes a new instance of the <see cref="BaseTime" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="configuration">The configuration.</param> protected BaseTime(ILogFactory log, BaseTimeConfiguration configuration) { Guard.NotNull(() => log, log); Guard.NotNull(() => configuration, configuration); Configuration = configuration; Log = log.Create(); }
/// <summary> /// Initializes a new instance of the <see cref="RollbackMessageDecorator" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="handler">The handler.</param> public RollbackMessageDecorator(ILogFactory log, IRollbackMessage handler) { Guard.NotNull(() => log, log); Guard.NotNull(() => handler, handler); _log = log.Create(); _handler = handler; }
/// <summary> /// Initializes a new instance of the <see cref="ReceiveMessageQueryDecorator" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="handler">The handler.</param> public DelayedProcessingActionDecorator(ILogFactory log, IDelayedProcessingAction handler) { Guard.NotNull(() => log, log); Guard.NotNull(() => handler, handler); _log = log.Create(); _handler = handler; }
/// <summary> /// Initializes a new instance of the <see cref="ReceivePoisonMessageDecorator" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="handler">The handler.</param> public ReceivePoisonMessageDecorator(ILogFactory log, IReceivePoisonMessage handler) { Guard.NotNull(() => log, log); Guard.NotNull(() => handler, handler); _log = log.Create(); _handler = handler; }
/// <summary> /// Initializes a new instance of the <see cref="ReceiveErrorMessage" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="dataDataStorage">The data data storage.</param> public ReceiveErrorMessage( ILogFactory log, IDataStorage dataDataStorage) { Guard.NotNull(() => dataDataStorage, dataDataStorage); Guard.NotNull(() => log, log); _log = log.Create(); _dataDataStorage = dataDataStorage; }
/// <inheritdoc /> public void Start() { //log task time (from time factory) and local machine time to show differences.. var log = _logFactory.Create("TIME"); log.Log(LogLevel.Info, () => $"Scheduler time is {_getTime.Create().GetCurrentUtcDate()}"); log.Log(LogLevel.Info, () => $"Local time is {DateTime.UtcNow}"); Task.Run(PollAsync); }
public FplDataManager(IContextFactory contextFactory, ILogFactory logFactory) { if (contextFactory == null) { throw new ArgumentNullException(nameof(contextFactory)); } _logger = logFactory.Create(); _contextFactory = contextFactory; }
public IDatabaseQuery StartQuery(bool withTransaction) { var connection = new OracleConnection(ConnectionString); OracleTransaction transaction = null; if (withTransaction) { try { connection.Open(); } catch (Exception ex) { LogFactory.Create("Oracle database layer - start query").Error(ex.ToString()); try { connection.Close(); } catch { } OracleConnection.ClearAllPools(); connection = new OracleConnection(ConnectionString); connection.Open(); } transaction = connection.BeginTransaction(); } IDatabaseQuery query; try { query = QueryFactory(connection, transaction, LogFactory); } catch (Exception ex) { var log = LogFactory.Create("Oracle database layer - start query"); log.Error(ex.ToString()); log.Info("Transactions: {0}, connections: {1}".With(OpenTransactions.Count, OpenConnections.Count)); throw; } if (withTransaction) { OpenTransactions.TryAdd(query, transaction); } OpenConnections.TryAdd(query, connection); return(query); }
public IDisposable Create([NotNull] TailViewModel tailView) { if (tailView == null) { throw new ArgumentNullException(nameof(tailView)); } var logger = _loggerFactory.Create <TailViewStateController>(); return(new TailViewStateController(tailView, _stateBucketService, _schedulerProvider, _tailViewStateRestorer, logger)); }
/// <summary> /// Initializes a new instance of the <see cref="SchedulerMessageHandler"/> class. /// </summary> /// <param name="log">The log.</param> /// <param name="metrics">metrics factory</param> public SchedulerMessageHandler(ILogFactory log, IMetrics metrics) { Guard.NotNull(() => log, log); Guard.NotNull(() => metrics, metrics); _log = log.Create(); var name = GetType().Name; _waitingOnFreeThreadCounter = metrics.Counter($"{name}.WaitingOnTaskCounter", Units.Items); }
public BeginTransactionRetryDecorator(ISqLiteTransactionWrapper decorated, ILogFactory log, ThreadSafeRandom threadSafeRandom) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => log, log); Guard.NotNull(() => threadSafeRandom, threadSafeRandom); _decorated = decorated; _log = log.Create(); _threadSafeRandom = threadSafeRandom; }
/// <summary> /// Initializes a new instance of the <see cref="ClearExpiredMessagesDecorator" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="handler">The handler.</param> /// <param name="connectionInfo">The connection information.</param> public ClearExpiredMessagesDecorator(ILogFactory log, IClearExpiredMessages handler, IConnectionInformation connectionInfo) { Guard.NotNull(() => log, log); Guard.NotNull(() => handler, handler); Guard.NotNull(() => connectionInfo, connectionInfo); _log = log.Create(); _handler = handler; _connectionInfo = connectionInfo; }
/// <summary> /// Initializes a new instance of the <see cref="ResetHeartBeatDecorator" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="handler">The handler.</param> /// <param name="configuration">The configuration.</param> public ResetHeartBeatDecorator(ILogFactory log, IResetHeartBeat handler, QueueConsumerConfiguration configuration) { Guard.NotNull(() => log, log); Guard.NotNull(() => handler, handler); Guard.NotNull(() => configuration, configuration); _log = log.Create(); _handler = handler; _configuration = configuration; }
/// <summary> /// Initializes a new instance of the <see cref="ClearExpiredMessagesDecorator" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="handler">The handler.</param> /// <param name="connectionInfo">The connection information.</param> public ClearExpiredMessagesDecorator(ILogFactory log, IClearExpiredMessages handler, IConnectionInformation connectionInfo) { Guard.NotNull(() => log, log); Guard.NotNull(() => handler, handler); Guard.NotNull(() => connectionInfo, connectionInfo); _log = log.Create(); _handler = handler; _connectionInfo = connectionInfo; }
/// <summary> /// Initializes a new instance of the <see cref="BaseMonitor" /> class. /// </summary> /// <param name="monitorAction">The monitor action.</param> /// <param name="monitorTimeSpan">The monitor time span.</param> /// <param name="log">The log.</param> protected BaseMonitor(Func <CancellationToken, long> monitorAction, IMonitorTimespan monitorTimeSpan, ILogFactory log) { Guard.NotNull(() => monitorAction, monitorAction); Guard.NotNull(() => monitorTimeSpan, monitorTimeSpan); Guard.NotNull(() => log, log); _monitorAction = monitorAction; _monitorTimeSpan = monitorTimeSpan; _log = log.Create(); }
/// <summary> /// Initializes a new instance of the <see cref="QueueStatusHttp"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="additionalConfiguration">The additional configuration.</param> /// <param name="serializer">The serializer.</param> /// <param name="log">The log.</param> public QueueStatusHttp( QueueStatusHttpConfiguration configuration, IConfiguration additionalConfiguration, IInternalSerializer serializer, ILogFactory log) { _log = log.Create(); _configuration = configuration; _serializer = serializer; Configuration = additionalConfiguration; _queueStatusProviders = new ConcurrentBag <IQueueStatusProvider>(); Configuration.SetSetting("QueueStatusHttpConfiguration", _configuration); }
/// <summary> /// Initializes a new instance of the <see cref="BaseMonitor" /> class. /// </summary> /// <param name="monitorAction">The monitor action.</param> /// <param name="monitorTimeSpan">The monitor time span.</param> /// <param name="log">The log.</param> protected BaseMonitor(Func<CancellationToken, long> monitorAction, IMonitorTimespan monitorTimeSpan, ILogFactory log) { Guard.NotNull(() => monitorAction, monitorAction); Guard.NotNull(() => monitorTimeSpan, monitorTimeSpan); Guard.NotNull(() => log, log); _monitorAction = monitorAction; _monitorTimeSpan = monitorTimeSpan; _log = log.Create(); _runningLock = new ReaderWriterLockSlim(); }
/// <summary> /// Initializes a new instance of the <see cref="BaseMonitor"/> class. /// </summary> /// <param name="monitorAction">The monitor action.</param> /// <param name="monitorTimeSpan">The monitor time span.</param> /// <param name="log">The log.</param> protected BaseMonitor(IMonitorTimespan monitorTimeSpan, Func <CancellationToken, List <ResetHeartBeatOutput> > monitorAction, ILogFactory log) { Guard.NotNull(() => monitorAction, monitorAction); Guard.NotNull(() => monitorTimeSpan, monitorTimeSpan); Guard.NotNull(() => log, log); _monitorActionIds = monitorAction; _monitorAction = null; _monitorTimeSpan = monitorTimeSpan; _log = log.Create(); }
/// <summary> /// Initializes a new instance of the <see cref="QueueStatusHttp"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="additionalConfiguration">The additional configuration.</param> /// <param name="serializer">The serializer.</param> /// <param name="log">The log.</param> public QueueStatusHttp( QueueStatusHttpConfiguration configuration, IConfiguration additionalConfiguration, IInternalSerializer serializer, ILogFactory log) { _log = log.Create(); _configuration = configuration; _serializer = serializer; Configuration = additionalConfiguration; _queueStatusProviders = new ConcurrentBag<IQueueStatusProvider>(); Configuration.SetSetting("QueueStatusHttpConfiguration", _configuration); }
/// <summary> /// Initializes a new instance of the <see cref="SchedulerTaskFactory" /> class. /// </summary> /// <param name="schedulerFactory">The scheduler factory.</param> /// <param name="log">The log.</param> public SchedulerTaskFactory(ITaskSchedulerFactory schedulerFactory, ILogFactory log) { Guard.NotNull(() => schedulerFactory, schedulerFactory); _scheduler = new Lazy <ATaskScheduler>(schedulerFactory.Create); _log = log.Create(); _factory = new Lazy <TaskFactory>(() => { lock (_tryStartNewLocker) { return(new TaskFactory(_scheduler.Value)); } }); }
/// <summary> /// Initializes a new instance of the <see cref="StopWorker"/> class. /// </summary> /// <param name="cancelWorkSource">The cancel work source.</param> /// <param name="configuration">The configuration.</param> /// <param name="log">The log.</param> /// <param name="waitForEventOrCancel">The wait for event or cancel.</param> public StopWorker(IQueueCancelWork cancelWorkSource, IWorkerConfiguration configuration, ILogFactory log, IWorkerWaitForEventOrCancel waitForEventOrCancel) { Guard.NotNull(() => cancelWorkSource, cancelWorkSource); Guard.NotNull(() => configuration, configuration); Guard.NotNull(() => log, log); Guard.NotNull(() => waitForEventOrCancel, waitForEventOrCancel); _cancelWorkSource = cancelWorkSource; _configuration = configuration; _log = log.Create(); _waitForEventOrCancel = waitForEventOrCancel; }
public PostgresConnectionPool(ConnectionInfo info, ILogFactory logFactory) { this.Info = info; if (!int.TryParse(ConfigurationManager.AppSettings["Database.PoolSize"], out Size)) Size = 20; if (!Enum.TryParse<PoolMode>(ConfigurationManager.AppSettings["Database.PoolMode"], out Mode)) Mode = PoolMode.IfAvailable; if (Mode != PoolMode.None) { if (Size < 1) Size = 1; for (int i = 0; i < Size; i++) Connections.Add(info.GetConnection()); } this.Logger = logFactory.Create("Npgsql connection manager"); }
/// <summary> /// Initializes a new instance of the <see cref="StopWorker"/> class. /// </summary> /// <param name="cancelWorkSource">The cancel work source.</param> /// <param name="configuration">The configuration.</param> /// <param name="log">The log.</param> /// <param name="waitForEventOrCancel">The wait for event or cancel.</param> public StopWorker(IQueueCancelWork cancelWorkSource, IWorkerConfiguration configuration, ILogFactory log, IWorkerWaitForEventOrCancel waitForEventOrCancel) { Guard.NotNull(() => cancelWorkSource, cancelWorkSource); Guard.NotNull(() => configuration, configuration); Guard.NotNull(() => log, log); Guard.NotNull(() => waitForEventOrCancel, waitForEventOrCancel); _cancelWorkSource = cancelWorkSource; _configuration = configuration; _log = log.Create(); _waitForEventOrCancel = waitForEventOrCancel; }
/// <summary> /// Initializes a new instance of the <see cref="AbortWorkerThreadDecorator" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="configuration">The configuration.</param> /// <param name="messageMode">The message mode.</param> /// <param name="handler">The handler.</param> public AbortWorkerThreadDecorator(ILogFactory log, IWorkerConfiguration configuration, MessageProcessingMode messageMode, IAbortWorkerThread handler) { Guard.NotNull(() => log, log); Guard.NotNull(() => handler, handler); Guard.NotNull(() => configuration, configuration); Guard.NotNull(() => messageMode, messageMode); _log = log.Create(); _handler = handler; _configuration = configuration; _messageMode = messageMode; }
/// <summary> /// Initializes a new instance of the <see cref="AbortWorkerThreadDecorator" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="configuration">The configuration.</param> /// <param name="messageMode">The message mode.</param> /// <param name="handler">The handler.</param> public AbortWorkerThreadDecorator(ILogFactory log, IWorkerConfiguration configuration, MessageProcessingMode messageMode, IAbortWorkerThread handler) { Guard.NotNull(() => log, log); Guard.NotNull(() => handler, handler); Guard.NotNull(() => configuration, configuration); Guard.NotNull(() => messageMode, messageMode); _log = log.Create(); _handler = handler; _configuration = configuration; _messageMode = messageMode; }
public JsonSerialization( GenericDeserializationBinder binder, ILogFactory logFactory) { Contract.Requires(binder != null); Contract.Requires(logFactory != null); this.Binder = binder; this.Logger = logFactory.Create(GetType().FullName); SharedSerializer = new JsonSerializer(); SharedSerializer.Converters.Add(new StringEnumConverter()); SharedSerializer.TypeNameHandling = TypeNameHandling.Auto; SharedSerializer.TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple; SharedSerializer.Binder = binder; }
/// <summary> /// Initializes a new instance of the <see cref="ProducerMethodJobQueue" /> class. /// </summary> /// <param name="jobSchedulerLastKnownEvent">The job scheduler last known event.</param> /// <param name="sendJobToQueue">The send job to queue.</param> /// <param name="logFactory">The log factory.</param> /// <param name="createJobQueue">The create job queue.</param> public ProducerMethodJobQueue(IJobSchedulerLastKnownEvent jobSchedulerLastKnownEvent, ISendJobToQueue sendJobToQueue, ILogFactory logFactory, IJobTableCreation createJobQueue) { Guard.NotNull(() => jobSchedulerLastKnownEvent, jobSchedulerLastKnownEvent); Guard.NotNull(() => sendJobToQueue, sendJobToQueue); Guard.NotNull(() => logFactory, logFactory); Guard.NotNull(() => createJobQueue, createJobQueue); LastKnownEvent = jobSchedulerLastKnownEvent; _sendJobToQueue = sendJobToQueue; Logger = logFactory.Create(); _createJobQueue = createJobQueue; }
/// <summary> /// Initializes a new instance of the <see cref="ProducerMethodJobQueue" /> class. /// </summary> /// <param name="jobSchedulerLastKnownEvent">The job scheduler last known event.</param> /// <param name="sendJobToQueue">The send job to queue.</param> /// <param name="logFactory">The log factory.</param> /// <param name="createJobQueue">The create job queue.</param> public ProducerMethodJobQueue(IJobSchedulerLastKnownEvent jobSchedulerLastKnownEvent, ISendJobToQueue sendJobToQueue, ILogFactory logFactory, IJobTableCreation createJobQueue) { Guard.NotNull(() => jobSchedulerLastKnownEvent, jobSchedulerLastKnownEvent); Guard.NotNull(() => sendJobToQueue, sendJobToQueue); Guard.NotNull(() => logFactory, logFactory); Guard.NotNull(() => createJobQueue, createJobQueue); LastKnownEvent = jobSchedulerLastKnownEvent; _sendJobToQueue = sendJobToQueue; Logger = logFactory.Create(); _createJobQueue = createJobQueue; }
public QueueProcessor( IMailService mailService, IQueryableRepository<IMailMessage> repository, IDataChangeNotification changeNotification, ILogFactory logFactory) { Contract.Requires(mailService != null); Contract.Requires(repository != null); Contract.Requires(changeNotification != null); Contract.Requires(logFactory != null); this.MailService = mailService; this.Repository = repository; this.ChangeNotification = changeNotification; this.Logger = logFactory.Create("Mail Queue processor"); }
/// <summary> /// Initializes a new instance of the <see cref="WorkerNotification" /> class. /// </summary> /// <param name="headerNames">The header names.</param> /// <param name="cancelWork">The cancel work.</param> /// <param name="configuration">The configuration.</param> /// <param name="log">The log.</param> /// <param name="metrics">The metrics factory.</param> public WorkerNotification(IHeaders headerNames, IQueueCancelWork cancelWork, TransportConfigurationReceive configuration, ILogFactory log, IMetrics metrics) { Guard.NotNull(() => headerNames, headerNames); Guard.NotNull(() => cancelWork, cancelWork); Guard.NotNull(() => configuration, configuration); Guard.NotNull(() => log, log); Guard.NotNull(() => metrics, metrics); HeaderNames = headerNames; WorkerStopping = cancelWork; TransportSupportsRollback = configuration.MessageRollbackSupported; Log = log.Create(); Metrics = metrics; }
/// <summary> /// Initializes a new instance of the <see cref="WorkerCollection"/> class. /// </summary> /// <param name="workerConfiguration">The worker configuration.</param> /// <param name="workerFactory">The worker factory.</param> /// <param name="stopWorker">The stop worker.</param> /// <param name="log">The log.</param> /// <param name="workerPause">The worker pause.</param> public WorkerCollection(IWorkerConfiguration workerConfiguration, IWorkerFactory workerFactory, StopWorker stopWorker, ILogFactory log, IWorkerWaitForEventOrCancel workerPause) { Guard.NotNull(() => workerConfiguration, workerConfiguration); Guard.NotNull(() => workerFactory, workerFactory); Guard.NotNull(() => stopWorker, stopWorker); Guard.NotNull(() => log, log); Guard.NotNull(() => workerPause, workerPause); _workerConfiguration = workerConfiguration; _workerFactory = workerFactory; _stopWorker = stopWorker; _log = log.Create(); _workerPause = workerPause; }
/// <summary> /// Initializes a new instance of the <see cref="Worker" /> class. /// </summary> /// <param name="nameFactory">The name factory.</param> /// <param name="pauseEvent">The pause event.</param> /// <param name="log">The log.</param> /// <param name="messageProcessing">The message processing.</param> /// <param name="workerTerminate">The worker terminate.</param> /// <param name="stopThead">The stop thread.</param> public Worker( IWorkerNameFactory nameFactory, IWorkerWaitForEventOrCancel pauseEvent, ILogFactory log, IMessageProcessingFactory messageProcessing, WorkerTerminate workerTerminate, StopThread stopThead) : base(workerTerminate, stopThead) { Guard.NotNull(() => pauseEvent, pauseEvent); Guard.NotNull(() => log, log); Guard.NotNull(() => nameFactory, nameFactory); _pauseEvent = pauseEvent; _log = log.Create(); _nameFactory = nameFactory; _messageProcessingFactory = messageProcessing; IdleStatus = WorkerIdleStatus.Unknown; }
/// <summary> /// Initializes a new instance of the <see cref="SqLiteMessageQueueReceiveErrorMessage" /> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="queryErrorRetryCount">The query error retry count.</param> /// <param name="commandSetErrorCount">The command set error count.</param> /// <param name="commandMoveRecord">The command move record.</param> /// <param name="log">The log.</param> /// <param name="headers">The headers.</param> public SqLiteMessageQueueReceiveErrorMessage(QueueConsumerConfiguration configuration, IQueryHandler<GetErrorRetryCountQuery, int> queryErrorRetryCount, ICommandHandler<SetErrorCountCommand> commandSetErrorCount, ICommandHandler<MoveRecordToErrorQueueCommand> commandMoveRecord, ILogFactory log, SqlHeaders headers) { Guard.NotNull(() => configuration, configuration); Guard.NotNull(() => queryErrorRetryCount, queryErrorRetryCount); Guard.NotNull(() => commandSetErrorCount, commandSetErrorCount); Guard.NotNull(() => commandMoveRecord, commandMoveRecord); Guard.NotNull(() => log, log); _configuration = configuration; _queryErrorRetryCount = queryErrorRetryCount; _commandSetErrorCount = commandSetErrorCount; _commandMoveRecord = commandMoveRecord; _log = log.Create(); _headers = headers; }
/// <summary> /// Initializes a new instance of the <see cref="MessageMethodHandling" /> class. /// </summary> /// <param name="serializer">The serializer.</param> /// <param name="queueContainer">The queue container.</param> /// <param name="log">The log.</param> /// <param name="linqCompiler">The method compiler.</param> /// <param name="compositeSerialization">The composite serialization.</param> public MessageMethodHandling(IExpressionSerializer serializer, IQueueContainer queueContainer, ILogFactory log, ILinqCompiler linqCompiler, ICompositeSerialization compositeSerialization) { Guard.NotNull(() => serializer, serializer); Guard.NotNull(() => queueContainer, queueContainer); Guard.NotNull(() => log, log); Guard.NotNull(() => linqCompiler, linqCompiler); Guard.NotNull(() => compositeSerialization, compositeSerialization); _serializer = serializer; _queueContainer = queueContainer; _linqCompiler = linqCompiler; _compositeSerialization = compositeSerialization; _log = log.Create(); _rpcQueues = new Dictionary<IConnectionInformation, IProducerQueueRpc<object>>(); }
public ScopePool( IObjectFactory factory, IDatabaseQueryManager queries, IExtensibilityProvider extensibilityProvider, ILogFactory logFactory) { this.Factory = factory; this.Queries = queries; if (!int.TryParse(ConfigurationManager.AppSettings["Processing.PoolSize"], out Size)) Size = 20; if (!Enum.TryParse<PoolMode>(ConfigurationManager.AppSettings["Processing.PoolMode"], out Mode)) Mode = PoolMode.IfAvailable; var commandTypes = extensibilityProvider.FindPlugins<IServerCommand>(); Factory.RegisterTypes(commandTypes, InstanceScope.Context); if (Mode != PoolMode.None) { if (Size < 1) Size = 1; for (int i = 0; i < Size; i++) Scopes.Add(SetupReadonlyScope()); } Logger = logFactory.Create("Scope pool"); }
/// <summary> /// Initializes a new instance of the <see cref="RedisQueueReceiveMessagesError"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="queryGetMetaData">The query get meta data.</param> /// <param name="saveMetaData">The save meta data.</param> /// <param name="commandMoveRecord">The command move record.</param> /// <param name="log">The log.</param> /// <param name="headers">The headers.</param> public RedisQueueReceiveMessagesError( QueueConsumerConfiguration configuration, IQueryHandler<GetMetaDataQuery, RedisMetaData> queryGetMetaData, ICommandHandler<SaveMetaDataCommand> saveMetaData, ICommandHandler<MoveRecordToErrorQueueCommand> commandMoveRecord, ILogFactory log, RedisHeaders headers) { Guard.NotNull(() => configuration, configuration); Guard.NotNull(() => queryGetMetaData, queryGetMetaData); Guard.NotNull(() => saveMetaData, saveMetaData); Guard.NotNull(() => commandMoveRecord, commandMoveRecord); Guard.NotNull(() => log, log); Guard.NotNull(() => headers, headers); _configuration = configuration; _queryGetMetaData = queryGetMetaData; _saveMetaData = saveMetaData; _commandMoveRecord = commandMoveRecord; _log = log.Create(); _headers = headers; }
/// <summary> /// Initializes a new instance of the <see cref="PrimaryWorker" /> class. /// </summary> /// <param name="nameFactory">The name factory.</param> /// <param name="log">The log.</param> /// <param name="messageProcessing">The message processing.</param> /// <param name="workerTerminate">The worker terminate.</param> /// <param name="workerCollection">The worker collection.</param> /// <param name="stopThead">The stop thread.</param> public PrimaryWorker( IWorkerNameFactory nameFactory, ILogFactory log, IMessageProcessingFactory messageProcessing, WorkerTerminate workerTerminate, IWorkerCollection workerCollection, StopThread stopThead) : base(workerTerminate, stopThead) { Guard.NotNull(() => nameFactory, nameFactory); Guard.NotNull(() => log, log); Guard.NotNull(() => messageProcessing, messageProcessing); Guard.NotNull(() => workerTerminate, workerTerminate); Guard.NotNull(() => workerCollection, workerCollection); _log = log.Create(); _nameFactory = nameFactory; _messageProcessingFactory = messageProcessing; _workerCollection = workerCollection; IdleStatus = WorkerIdleStatus.Unknown; }
/// <summary> /// Initializes a new instance of the <see cref="WaitForThreadToFinish"/> class. /// </summary> /// <param name="log">The log.</param> public WaitForThreadToFinish(ILogFactory log) { Guard.NotNull(() => log, log); _log = log.Create(); }
public QueryInterceptor(ILogFactory logFactory) { Contract.Requires(logFactory != null); this.Logger = logFactory.Create("Database performance trace"); }
public RestCommandsIntercepter(ILogFactory logFactory) { Contract.Requires(logFactory != null); this.Logger = logFactory.Create("REST commands trace"); }
public DynamicCodeCompiler(ILogFactory log) { _compiler = new Compiler(); _log = log.Create(); }
/// <summary> /// Initializes a new instance of the <see cref="MessageProcessing"/> class. /// </summary> /// <param name="receiveMessages">The receive messages.</param> /// <param name="messageContextFactory">The message context factory.</param> /// <param name="queueWaitFactory">The queue wait factory.</param> /// <param name="log">The log.</param> /// <param name="processMessage">The process message.</param> /// <param name="receivePoisonMessage">The receive poison message.</param> /// <param name="rollbackMessage">rolls back a message when an exception occurs</param> public MessageProcessing( IReceiveMessagesFactory receiveMessages, IMessageContextFactory messageContextFactory, IQueueWaitFactory queueWaitFactory, ILogFactory log, ProcessMessage processMessage, IReceivePoisonMessage receivePoisonMessage, IRollbackMessage rollbackMessage) { Guard.NotNull(() => receiveMessages, receiveMessages); Guard.NotNull(() => messageContextFactory, messageContextFactory); Guard.NotNull(() => queueWaitFactory, queueWaitFactory); Guard.NotNull(() => log, log); Guard.NotNull(() => processMessage, processMessage); Guard.NotNull(() => receivePoisonMessage, receivePoisonMessage); Guard.NotNull(() => rollbackMessage, rollbackMessage); _receiveMessages = receiveMessages.Create(); _messageContextFactory = messageContextFactory; _log = log.Create(); _processMessage = processMessage; _receivePoisonMessage = receivePoisonMessage; _rollbackMessage = rollbackMessage; _noMessageToProcessBackoffHelper = new Lazy<IQueueWait>(queueWaitFactory.CreateQueueDelay); _seriousExceptionProcessBackOffHelper = new Lazy<IQueueWait>(queueWaitFactory.CreateFatalErrorDelay); }