Example #1
0
        /// <summary>
        /// Adds a converter for the specified event to be used when upgrading events.
        /// </summary>
        /// <remarks>
        /// <para>You do not need to add a converter for every event, only those that require upgrading.
        /// If an event has no converter added it will be left un-modified.</para>
        /// </remarks>
        /// <param name="eventName">The name of the event the <paramref name="converter"/> handles.</param>
        /// <param name="converter">The converter for the event specified by <paramref name="eventName"/>.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="eventName"/> or <paramref name="converter"/> is <value>null</value>.</exception>
        /// <exception cref="ArgumentException">If a converter for <paramref name="eventName"/> has already been added.</exception>
        public void AddConverter(string eventName, IEventConverter converter)
        {
            Contract.Requires<ArgumentNullException>(eventName != null, "eventName");
            Contract.Requires<ArgumentNullException>(converter != null, "converter");

            ThrowIfNameExists(eventName);
            _converters.Add(eventName, converter);
        }
Example #2
0
        /// <summary>
        /// Adds a converter for the specified event to be used when upgrading events.
        /// </summary>
        /// <remarks>
        /// <para>This uses the type resolver to look up the name of the event.</para>
        /// <para>You do not need to add a converter for every event, only those that require upgrading.
        /// If an event has no converter added it will be left un-modified.</para>
        /// </remarks>
        /// <param name="eventType">The event type the <paramref name="converter"/> handles.</param>
        /// <param name="converter">The converter for the event specified by <paramref name="eventType"/>.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="eventType"/> or <paramref name="converter"/> is <value>null</value>.</exception>
        /// <exception cref="ArgumentException">If a converter for <paramref name="eventType"/> has already been added.</exception>
        public void AddConverter(Type eventType, IEventConverter converter)
        {
            Contract.Requires<ArgumentNullException>(eventType != null, "eventType");
            Contract.Requires<ArgumentNullException>(converter != null, "converter");

            string name = _typeResolver.EventNameFor(eventType);
            AddConverter(name, converter);
        }
Example #3
0
 	/// <summary>
 	/// Initializes a new instance of <see cref="EventRepository"/>
 	/// </summary>
 	/// <param name="entityContext"><see cref="IEntityContext{T}"/> for retrieving events</param>
 	/// <param name="eventConverter"><see cref="IEventConverter"/> for converting events</param>
     /// <param name="eventMigrationHierarchyManager">A <see cref="IEventMigrationHierarchyManager"/> for managing event migrations</param>
     public EventRepository(
         IEntityContext<EventHolder> entityContext, 
         IEventConverter eventConverter, 
         IEventMigrationHierarchyManager eventMigrationHierarchyManager)
 	{
 		_entityContext = entityContext;
 		_eventConverter = eventConverter;
         _eventMigrationHierarchyManager = eventMigrationHierarchyManager;
 	}
Example #4
0
        public MsSqlServerEventStore(String connectionString, IEventTypeResolver typeResolver, IEventConverter converter)
        {
            if (String.IsNullOrEmpty(connectionString)) throw new ArgumentNullException("connectionString");

            _connectionString = connectionString;
            _converter = converter ?? new NullEventConverter();
            _formatter = new JsonEventFormatter(typeResolver ?? new SimpleEventTypeResolver());
            _translator = new StringEventTranslator();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommittedEventsFetcher"/> class.
 /// </summary>
 /// <param name="streams">The <see cref="IStreams"/>.</param>
 /// <param name="eventConverter">The <see cref="IEventConverter" />.</param>
 /// <param name="aggregateRoots">The <see cref="IAggregateRoots" />.</param>
 public CommittedEventsFetcher(
     IStreams streams,
     IEventConverter eventConverter,
     IAggregateRoots aggregateRoots)
 {
     _streams        = streams;
     _eventConverter = eventConverter;
     _aggregateRoots = aggregateRoots;
 }
Example #6
0
 public InaraPlugin(IPlayerStateHistoryRecorder playerStateRecorder, ISettingsProvider settingsProvider, IRestClientFactory restClientFactory)
     : base(settingsProvider)
 {
     RestClient = restClientFactory.CreateRestClient(InaraApiUrl);
     this.playerStateRecorder          = playerStateRecorder;
     eventConverter                    = new InaraEventConverter(this.playerStateRecorder);
     this.settingsProvider             = settingsProvider;
     settingsProvider.SettingsChanged += (o, e) => ReloadSettings();
     ReloadSettings();
 }
Example #7
0
        public EventConverterTests()
        {
            _typeResolver = MockRepository.GenerateStub <IEventTypeResolver>();
            _typeResolver
            .Stub(x => x.EventNameFor(typeof(AnEvent)))
            .TentativeReturn()
            .Return(EventName);

            _childConverter = MockRepository.GenerateStub <IEventConverter>();
        }
        public void SetUp()
        {
            _typeResolver = MockRepository.GenerateStub<IEventTypeResolver>();
            _typeResolver
                .Stub(x => x.EventNameFor(typeof(AnEvent)))
                .TentativeReturn()
                .Return(EventName);

            _childConverter = MockRepository.GenerateStub<IEventConverter>();
        }
 public EventStoreHubInitializer(IEventStoreFacade connection,
                                 IHubContext <EventStoreHub> hubConnection, ILogger logger,
                                 IEventConverter eventConveter,
                                 IProjectionSchemaRegister projectionSchema)
 {
     this._connection       = connection;
     this._hubConnection    = hubConnection;
     this._logger           = logger;
     this._eventConverter   = eventConveter;
     this._projectionSchema = projectionSchema;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FilterProcessors"/> class.
 /// </summary>
 /// <param name="client">The <see cref="FiltersClient"/> to use to connect to the Runtime.</param>
 /// <param name="reverseCallClients">The <see cref="IReverseCallClients"/> to use for creating instances of <see cref="IReverseCallClient{TClientMessage, TServerMessage, TConnectArguments, TConnectResponse, TRequest, TResponse}"/>.</param>
 /// <param name="converter">The <see cref="IEventConverter"/> to use to convert events.</param>
 /// <param name="loggerManager">The <see cref="ILoggerManager"/> to use for creating instances of <see cref="ILogger"/>.</param>
 public FilterProcessors(
     FiltersClient client,
     IReverseCallClients reverseCallClients,
     IEventConverter converter,
     ILoggerManager loggerManager)
 {
     _client             = client;
     _reverseCallClients = reverseCallClients;
     _converter          = converter;
     _loggerManager      = loggerManager;
 }
Example #11
0
        public MongoDBEventStore(string connectionString = DEFAULT_DATABASE_URI, IEventTypeResolver typeResolver = null, IEventConverter converter = null)
        {
            _database = MongoDatabase.Create(connectionString);
            _commits = _database.GetCollection<MongoCommit>("Commits");
            _events = _database.GetCollection<BsonDocument>("SourcedEvents");

            _converter = converter ?? new NullEventConverter();
            _formatter = new JsonEventFormatter(typeResolver ?? new SimpleEventTypeResolver());
            _translator = new StringEventTranslator();

            EnsureIndexes();
        }
 public ProjectionEventStream(IEventStoreFacade connection,
                              IEventConverter eventConveter,
                              IEventDataFactory eventDataFactory,
                              IProjectionSchema <TProjection> projectionSchema)
 {
     _connection           = connection;
     _eventConveter        = eventConveter;
     _eventDataFactory     = eventDataFactory;
     _projectionSchema     = projectionSchema;
     _projectionStreamName =
         $"{ServiceConventions.GetCategoryFromNamespace(typeof(TProjection).Namespace)}Projection";
 }
Example #13
0
        public PostgreServerEventStore(String connectionString, IEventTypeResolver typeResolver, IEventConverter converter)
        {
            if (String.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException("connectionString");
            }

            _connectionString = connectionString;
            _converter        = converter ?? new NullEventConverter();
            _formatter        = new JsonEventFormatter(typeResolver ?? new SimpleEventTypeResolver());
            _translator       = new StringEventTranslator();
        }
Example #14
0
        public MongoDBEventStore(string connectionString = DEFAULT_DATABASE_URI, IEventTypeResolver typeResolver = null, IEventConverter converter = null)
        {
            _database = MongoDatabase.Create(connectionString);
            _commits  = _database.GetCollection <MongoCommit>("Commits");
            _events   = _database.GetCollection <BsonDocument>("SourcedEvents");

            _converter  = converter ?? new NullEventConverter();
            _formatter  = new JsonEventFormatter(typeResolver ?? new SimpleEventTypeResolver());
            _translator = new StringEventTranslator();

            EnsureIndexes();
        }
Example #15
0
        public EdsmPlugin(ISettingsProvider settingsProvider, IPlayerStateHistoryRecorder playerStateRecorder, IRestClientFactory restClientFactory)
            : base(settingsProvider)
        {
            RestClient = restClientFactory.CreateRestClient(EdsmApiUrl);
            this.playerStateRecorder = playerStateRecorder ?? throw new ArgumentNullException(nameof(playerStateRecorder));
            eventConverter           = new EdsmEventConverter(playerStateRecorder);
            ignoredEvents            =
                RestClient.GetAsync("discard")
                .ContinueWith((t) => t.IsFaulted ? new HashSet <string>() : new HashSet <string>(JArray.Parse(t.Result).ToObject <string[]>()));

            settingsProvider.SettingsChanged += (o, e) => ReloadSettings();
            ReloadSettings();
        }
        public async Task given_unhandlable_message_then_sut_ignores_it(
            IEventConverter converter,
            IMessageHandler handler,
            Message message)
        {
            Mock.Get(handler).Setup(x => x.CanHandle(It.IsAny <Message>())).Returns(false);
            EventProcessor sut       = new EventProcessorBuilder(converter, handler).Build();
            EventData      eventData = converter.ConvertToEvent(message);

            await sut.Process(new[] { eventData });

            Mock.Get(handler).Verify(x => x.Handle(It.IsAny <Message>()), Times.Never());
        }
 public AggregateEventStream(IEventStoreFacade connection,
                             IEventConverter eventConverter,
                             IEventDataFactory eventDataFactory,
                             IEventMetadataFactory <TAggregate> metadataFactory,
                             IAggregateSchema <TAggregate> aggregateSchema, Serilog.ILogger logger)
 {
     _connection       = connection;
     _eventConverter   = eventConverter;
     _eventDataFactory = eventDataFactory;
     _metadataFactory  = metadataFactory;
     _aggregateSchema  = aggregateSchema;
     _logger           = logger;
 }
Example #18
0
        public static async Task BindToSignalHub(this IEventStoreFacade connection,
                                                 IEventConverter eventConverter,
                                                 IProjectionSchemaRegister projectionSchema,
                                                 IHubContext <EventStoreHub> hubConnection, Serilog.ILogger logger)
        {
            foreach (var e in projectionSchema.Events)
            {
                var configuratorType = typeof(SignalRConfigurator <>).MakeGenericType(e);
                var configurator     = Ctor <ISignalRConfigurator> .Create(configuratorType);

                await configurator.Configure(connection, eventConverter, hubConnection, logger);
            }
        }
 public ProjectionMultiEventStreamSubscriptionProvider(IEventStoreFacade eventStore,
                                                       IEventConverter eventConverter,
                                                       IProjectionEventStreamRepository repo,
                                                       IProjectionEventStream stream,
                                                       IProjectionSchema schema)
 {
     _eventStore     = eventStore;
     _eventConverter = eventConverter;
     _repo           = repo;
     _stream         = stream;
     _schema         = schema;
     _events         = new HashSet <Type>();
 }
Example #20
0
            public async Task Configure(IEventStoreFacade connection,
                                        IEventConverter eventConverter,
                                        IHubContext <EventStoreHub> hubConnection, Serilog.ILogger logger)
            {
                Log        = logger;
                _converter = eventConverter;
                var stream = $"$et-{typeof(TEvent).Name}";

                this._connection = hubConnection;
                var t = await connection.SubscribeToStreamAsync(stream, StreamRevision.Start, OnReadEvent, null, true);

                Log.Information("Subscribed for {eventName} for pushing to signalR clients.", typeof(TEvent).Name);
            }
 /// <summary>
 /// Initializes a new instance of the <see cref="PublicEventFilterProcessor"/> class.
 /// </summary>
 /// <param name="filterId">The unique <see cref="FilterId"/> for the event filter.</param>
 /// <param name="client">The <see cref="FiltersClient"/> to use to connect to the Runtime.</param>
 /// <param name="reverseCallClients">The <see cref="IReverseCallClients"/> to use for creating instances of <see cref="IReverseCallClient{TClientMessage, TServerMessage, TConnectArguments, TConnectResponse, TRequest, TResponse}"/>.</param>
 /// <param name="filter">The <see cref="ICanFilterPublicEvents"/> to use for filtering the events.</param>
 /// <param name="converter">The <see cref="IEventConverter"/> to use to convert events.</param>
 /// <param name="logger">The <see cref="ILogger"/> to use for logging.</param>
 public PublicEventFilterProcessor(
     FilterId filterId,
     FiltersClient client,
     IReverseCallClients reverseCallClients,
     ICanFilterPublicEvents filter,
     IEventConverter converter,
     ILogger logger)
     : base(filterId, converter, logger)
 {
     _client             = client;
     _reverseCallClients = reverseCallClients;
     _filter             = filter;
 }
Example #22
0
        public void SetUp()
        {
            _typeResolver = MockRepository.GenerateStub <IEventTypeResolver>();
            _typeResolver
            .Stub(x => x.EventNameFor(typeof(AnEvent)))
            .TentativeReturn()
            .Return(EventName);
            _typeResolver
            .Stub(x => x.ResolveType(EventName))
            .TentativeReturn()
            .Return(CreateEvent(EventName).GetType());

            _childConverter = MockRepository.GenerateStub <IEventConverter>();
        }
Example #23
0
 public CommittedEventStreamSender(
     IPublisher publisher,
     ICommittedEventStreamBridge bridge,
     IEventConverter eventConverter,
     ISerializer serializer,
     CommittedEventStreamSenderConfiguration senderConfiguration,
     ILogger logger)
 {
     _publisher           = publisher;
     _eventConverter      = eventConverter;
     _bridge              = bridge;
     _serializer          = serializer;
     _senderConfiguration = senderConfiguration;
     _logger              = logger;
 }
        public async Task given_unknown_type_then_sut_ignores_message(
            IEventConverter converter,
            LoggingMessageHandler spy,
            Message message,
            string unknownType)
        {
            EventProcessor sut       = new EventProcessorBuilder(converter, spy).Build();
            EventData      eventData = converter.ConvertToEvent(message);

            eventData.Properties["Type"] = unknownType;

            await sut.Process(new[] { eventData });

            spy.Log.Should().BeEmpty();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventStore"/> class.
 /// </summary>
 /// <param name="eventStoreClient">The event store grpc client.</param>
 /// <param name="artifactMap">The <see cref="IArtifactTypeMap" />.</param>
 /// <param name="eventConverter">The <see cref="IEventConverter" />.</param>
 /// <param name="executionContextManager">An <see cref="IExecutionContextManager"/> for getting execution context from.</param>
 /// <param name="head">The current <see cref="Head"/>.</param>
 /// <param name="logger">The <see cref="ILogger" />.</param>
 public EventStore(
     EventStoreClient eventStoreClient,
     IArtifactTypeMap artifactMap,
     IEventConverter eventConverter,
     IExecutionContextManager executionContextManager,
     Head head,
     ILogger logger)
 {
     _artifactMap             = artifactMap;
     _eventStoreClient        = eventStoreClient;
     _eventConverter          = eventConverter;
     _executionContextManager = executionContextManager;
     _head   = head;
     _logger = logger;
 }
Example #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventHandlerProcessors"/> class.
 /// </summary>
 /// <param name="handlersClient">The <see cref="EventHandlersClient"/> to use to connect to the Runtime.</param>
 /// <param name="reverseCallClients">The <see cref="IReverseCallClients"/> to use for creating instances of <see cref="IReverseCallClient{TClientMessage, TServerMessage, TConnectArguments, TConnectResponse, TRequest, TResponse}"/>.</param>
 /// <param name="eventProcessingCompletion">The <see cref="IEventProcessingCompletion"/> to use for notifying of event handling completion.</param>
 /// <param name="artifactTypeMap">The <see cref="IArtifactTypeMap"/> to use for converting event types to artifacts.</param>
 /// <param name="converter">The <see cref="IEventConverter"/> to use to convert events.</param>
 /// <param name="loggerManager">The <see cref="ILoggerManager"/> to use for creating instances of <see cref="ILogger"/>.</param>
 public EventHandlerProcessors(
     EventHandlersClient handlersClient,
     IReverseCallClients reverseCallClients,
     IEventProcessingCompletion eventProcessingCompletion,
     IArtifactTypeMap artifactTypeMap,
     IEventConverter converter,
     ILoggerManager loggerManager)
 {
     _handlersClient            = handlersClient;
     _reverseCallClients        = reverseCallClients;
     _eventProcessingCompletion = eventProcessingCompletion;
     _artifactTypeMap           = artifactTypeMap;
     _converter     = converter;
     _loggerManager = loggerManager;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventFilterWithPartitionsProcessor"/> class.
 /// </summary>
 /// <param name="filterId">The unique <see cref="FilterId"/> for the event filter.</param>
 /// <param name="scope">The <see cref="ScopeId"/> of the scope in the Event Store where the filter will run.</param>
 /// <param name="client">The <see cref="FiltersClient"/> to use to connect to the Runtime.</param>
 /// <param name="reverseCallClients">The <see cref="IReverseCallClients"/> to use for creating instances of <see cref="IReverseCallClient{TClientMessage, TServerMessage, TConnectArguments, TConnectResponse, TRequest, TResponse}"/>.</param>
 /// <param name="filter">The <see cref="ICanFilterEventsWithPartition"/> to use for filtering the events.</param>
 /// <param name="converter">The <see cref="IEventConverter"/> to use to convert events.</param>
 /// <param name="logger">The <see cref="ILogger"/> to use for logging.</param>
 public EventFilterWithPartitionsProcessor(
     FilterId filterId,
     ScopeId scope,
     FiltersClient client,
     IReverseCallClients reverseCallClients,
     ICanFilterEventsWithPartition filter,
     IEventConverter converter,
     ILogger logger)
     : base(filterId, converter, logger)
 {
     _scope              = scope;
     _client             = client;
     _reverseCallClients = reverseCallClients;
     _filter             = filter;
 }
Example #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="activitiEvent"></param>
        /// <returns></returns>
        public virtual IProcessEngineEvent From(IActivitiEvent activitiEvent)
        {
            IEventConverter converter = convertersMap[GetPrefix(activitiEvent) + activitiEvent.Type];

            IProcessEngineEvent newEvent = null;

            if (converter != null)
            {
                newEvent = converter.From(activitiEvent);
            }
            else
            {
                logger.LogDebug(">> Ommited Event Type: " + activitiEvent.GetType().FullName);
            }
            return(newEvent);
        }
        public async Task sut_processes_event_correctly(
            IEventConverter converter,
            LoggingMessageHandler spy,
            string id,
            MessageData1 data,
            TracingProperties tracingProperties)
        {
            EventProcessor sut       = new EventProcessorBuilder(converter, spy).Build();
            var            message   = new Message(id, data, tracingProperties);
            EventData      eventData = converter.ConvertToEvent(message);

            await sut.Process(new[] { eventData });

            spy.Log.Should().ContainSingle();
            spy.Log.Single().Should().BeEquivalentTo(message);
        }
Example #30
0
        public TeamCityEventListener(TextWriter outWriter, ITeamCityInfo teamCityInfo)
        {
            if (outWriter == null)
            {
                throw new ArgumentNullException("outWriter");
            }
            if (teamCityInfo == null)
            {
                throw new ArgumentNullException("teamCityInfo");
            }

            _outWriter    = outWriter;
            _teamCityInfo = teamCityInfo;

            _serviceMessageWriter = new ServiceMessageWriter();
            var serviceMessageFactory = new ServiceMessageFactory(_teamCityInfo, new SuiteNameReplacer(_teamCityInfo));
            var hierarchy             = new Hierarchy();

            _eventConverter2 = new EventConverter2(serviceMessageFactory, hierarchy, _statistics, _teamCityInfo);
            _eventConverter3 = new EventConverter3(serviceMessageFactory, hierarchy, _statistics, _teamCityInfo);
            RootFlowId       = _teamCityInfo.RootFlowId;
        }
Example #31
0
        /// <summary>Initializes a new instance of the <see cref="MsSqlServerEventStore"/> class.</summary>
        /// <param name="connectionString">The database connection string to the database.</param>
        /// <param name="applicationName">The application name that is used to isolate events and surces etc...</param>
        /// <param name="typeResolver">Indicates the <see cref="IEventTypeResolver"/> to use.</param>
        /// <param name="converter">Indicates the <see cref="IEventConverter"/> to use.</param>
        public MultiAppSqlServerEventStore(
            string connectionString,
            string applicationName,
            IEventTypeResolver typeResolver,
            IEventConverter converter)
        {
            if (String.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException("connectionString");
            }

            if (String.IsNullOrEmpty(applicationName))
            {
                throw new ArgumentNullException("applicationName");
            }

            _connectionString = connectionString;
            _applicationName  = applicationName;
            _converter        = converter ?? new NullEventConverter();
            _formatter        = new JsonEventFormatter(typeResolver ?? new SimpleEventTypeResolver());
            _translator       = new StringEventTranslator();

            InitializeEventStore();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventHandlerProcessor{TEventType}"/> class.
 /// </summary>
 /// <param name="handlerId">The unique <see cref="EventHandlerId"/> for the event handler.</param>
 /// <param name="scope">The <see cref="ScopeId"/> of the scope in the Event Store where the event handler will run.</param>
 /// <param name="partitioned">Whether the event handler should create a partitioned stream or not.</param>
 /// <param name="handler">The <see cref="IEventHandler{TEventType}"/> that will be called to handle incoming events.</param>
 /// <param name="client">The <see cref="EventHandlersClient"/> to use to connect to the Runtime.</param>
 /// <param name="reverseCallClients">The <see cref="IReverseCallClients"/> to use for creating instances of <see cref="IReverseCallClient{TClientMessage, TServerMessage, TConnectArguments, TConnectResponse, TRequest, TResponse}"/>.</param>
 /// <param name="completion">The <see cref="IEventProcessingCompletion"/> to use for notifying of event handling completion.</param>
 /// <param name="artifacts">The <see cref="IArtifactTypeMap"/> to use for converting event types to artifacts.</param>
 /// <param name="converter">The <see cref="IEventConverter"/> to use to convert events.</param>
 /// <param name="logger">The <see cref="ILogger"/> to use for logging.</param>
 public EventHandlerProcessor(
     EventHandlerId handlerId,
     ScopeId scope,
     bool partitioned,
     IEventHandler <TEventType> handler,
     EventHandlersClient client,
     IReverseCallClients reverseCallClients,
     IEventProcessingCompletion completion,
     IArtifactTypeMap artifacts,
     IEventConverter converter,
     ILogger logger)
     : base(logger)
 {
     Identifier          = handlerId;
     _scope              = scope;
     _partitioned        = partitioned;
     _handler            = handler;
     _client             = client;
     _reverseCallClients = reverseCallClients;
     _completion         = completion;
     _artifacts          = artifacts;
     _converter          = converter;
     _logger             = logger;
 }
Example #33
0
        async override protected Task <SendEventResults> SendEventsAsync(object myClient, TheSenderThing azureThing, CancellationToken cancelToken, IEnumerable <nsCDEngine.ViewModels.TheThingStore> thingUpdatesToSend, IEventConverter eventConverter)
        {
            var client = myClient as TheREST;

            if (client == null)
            {
                throw new Exception("Internal error: Invalid or null client");
            }
            var results = new SendEventResults();

            results.SendTasks = new List <Task>();
            var  messagePayloads = eventConverter.GetEventData(thingUpdatesToSend, azureThing, maxEventDataSize, false);
            long batchLength     = 0;

            foreach (var msgObj in messagePayloads)
            {
                var msgString     = msgObj as string;
                var correlationId = Guid.NewGuid();

                try
                {
                    var  postCS   = new TaskCompletionSource <bool>();
                    Task sendTask = postCS.Task;
                    if (msgString != null)
                    {
                        var payload = Encoding.UTF8.GetBytes(msgString);

                        client.PostRESTAsync(new Uri($"{HttpTargetUrl}"),
                                             rd => {
                            postCS.TrySetResult(true);
                        }, payload, "application/json", Guid.Empty, null, rd => {
                            if (EnableLogSentPayloads)
                            {
                                try
                                {
                                    string strFilePath = TheCommonUtils.cdeFixupFileName("httpsenderdata.log");
                                    System.IO.File.AppendAllText(strFilePath, $"{{\"TimePublished\":\"{DateTimeOffset.Now:O}\", \"PLS\": {rd?.ErrorDescription}}},\r\n");
                                }
                                catch (Exception e)
                                {
                                    TheBaseAssets.MySYSLOG.WriteToLog(95307, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(strPrometheusExporter, $"Unable to log data to file: {this.MyBaseThing?.Address} - {thingUpdatesToSend.Count()}", eMsgLevel.l3_ImportantMessage, e.ToString()));
                                }
                            }
                            postCS.TrySetException(new Exception($"PostRESTAsync Failed: {rd?.ErrorDescription}"));
                        }, null);

                        batchLength += msgString.Length;
                        if (EnableLogSentPayloads)
                        {
                            try
                            {
                                string strFilePath = TheCommonUtils.cdeFixupFileName("httpsenderdata.log");
                                System.IO.File.AppendAllText(strFilePath, $"{{\"TimePublished\":\"{DateTimeOffset.Now:O}\", \"Body\": {msgString}}},\r\n");
                            }
                            catch (Exception e)
                            {
                                TheBaseAssets.MySYSLOG.WriteToLog(95307, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(strPrometheusExporter, $"Unable to log data to file: {this.MyBaseThing?.Address} - {thingUpdatesToSend.Count()}", eMsgLevel.l3_ImportantMessage, e.ToString()));
                            }
                        }

                        Interlocked.Increment(ref _pendingKPIs.EventScheduledCount);
                    }
                    else
                    {
                        postCS.TrySetException(new InvalidTransportEncodingException());
                    }
                    results.SendTasks.Add(sendTask);
                    if (GetPreserveOrderForSenderThing(azureThing))
                    {
                        await sendTask;
                    }
                }
                catch (Exception e)
                {
                    TheBaseAssets.MySYSLOG.WriteToLog(95307, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(strPrometheusExporter, $"Internal error: {this.MyBaseThing?.Address} - {thingUpdatesToSend.Count()}", eMsgLevel.l3_ImportantMessage, e.ToString()));
                }

                cancelToken.ThrowIfCancellationRequested();
            }
            results.SizeSent = batchLength;
            return(results);
        }
Example #34
0
 public EventfulClient()
 {
     this.EventConverter = new EventfulConverter();
 }
		public EventStoreStreamRepository(IEventStoreConnection connection, IEventConverter eventConverter)
		{
			_connection = connection;
			_eventConverter = eventConverter;
		}
Example #36
0
        /// <summary>
        /// Initializes a new instance of <see cref="SagaConverter"/>
        /// </summary>
        /// <param name="container">A <see cref="IContainer"/> for creating instances of types</param>
        /// <param name="eventConverter">A <see cref="IEventConverter"/> for converting any <see cref="IEvent">events</see> in a <see cref="ISaga"/></param>
        /// <param name="serializer">A <see cref="ISerializer"/> to use for serialization</param>
		public SagaConverter(IContainer container, IEventConverter eventConverter, ISerializer serializer)
		{
			_container = container;
			_eventConverter = eventConverter;
			_serializer = serializer;
		}
Example #37
0
 public YelpClient()
 {
     this.EventConverter = new YelpConverter();
 }
 public InMemoryEventStore(IEventPublisher publisher, IEventConverter converter)
 {
   _publisher = publisher;
   _converter = converter;
 }