private async Task <EventStoreReader> GetSut()
        {
            var transformer = new EventTransformator(new JsonEventSerializer(new EventTypeResolver()));
            var reader      = new EventStoreReader(await LocalConfig.GetConnection(), transformer);

            return(reader);
        }
Beispiel #2
0
        // format: serviceId="myapp~app1~svc1" for fabric:/myapp/app1/svc1
        private static void HandleServicesEvents(IResultWriter writer, string serviceId, QueryParametersWrapper queryParameters)
        {
            if (!ValidateStartAndEndTime(queryParameters.StartTimeUtc, queryParameters.EndTimeUtc))
            {
                OnUnsupportedUri(writer);
                return;
            }

            if (!string.IsNullOrWhiteSpace(serviceId))
            {
                serviceId = ConvertServiceIdToFullUri(serviceId);
            }

            var queryTracker = QueryStatTracker.CreateAndMarkQueryStart(ReaderConstants.Services, serviceId, queryParameters);
            var events       = new EventStoreReader()
                               .GetServiceEventsAsync(
                serviceId,
                new Duration(
                    queryParameters.StartTimeUtc,
                    queryParameters.EndTimeUtc),
                ConvertUserEventTypesToUnderlyingTypes(
                    EntityType.Service,
                    queryParameters.EventsTypesFilter),
                CancellationToken.None)
                               .GetAwaiter()
                               .GetResult()
                               .ToArray();

            queryTracker.MarkQueryEnd(events.Count());

            writer.Write(new JsonSerializerHelper().SerializeObject(events.Take(MaxRecordsInResult).OrderBy(item => item.TimeStamp)));
        }
Beispiel #3
0
            public TestContainer(EvenTestKit testKit)
            {
                var a = testKit.CreateTestRelay();
                var b = testKit.CreateTestRelay();
                var c = testKit.CreateTestRelay();
                var e = testKit.CreateTestRelay();
                var d = testKit.CreateTestRelay();

                ReadProbe                          = a.Probe;
                ReadStreamProbe                    = b.Probe;
                ReadIndexedProjectionProbe         = c.Probe;
                ReadProjectionIndexCheckpointProbe = d.Probe;
                ReadHighestGlobalSequenceProbe     = e.Probe;

                var readerProps = EventStoreReader.CreateProps(a.Props, b.Props, c.Props, d.Props, e.Props, new GlobalOptions());

                Reader = testKit.Sys.ActorOf(readerProps);
            }
Beispiel #4
0
        private static void HandleCorrelatedEvents(IResultWriter writer, string eventInstanceId, QueryParametersWrapper queryParameters)
        {
            if (string.IsNullOrWhiteSpace(eventInstanceId))
            {
                EventStoreLogger.Logger.LogWarning("HandleCorrelatedEvents:: Event Instance id in param is empty/null");
                OnUnsupportedUri(writer);
                return;
            }

            var eventInstanceGuid = Guid.Empty;

            if (!Guid.TryParse(eventInstanceId, out eventInstanceGuid))
            {
                EventStoreLogger.Logger.LogWarning("HandleCorrelatedEvents:: EventInstance ID : {0} Is not a valid Guid", eventInstanceId);
                OnUnsupportedUri(writer);
                return;
            }

            if (eventInstanceGuid == Guid.Empty)
            {
                EventStoreLogger.Logger.LogWarning("HandleCorrelatedEvents:: Empty Guid for Event Instance Id");
                OnUnsupportedUri(writer);
                return;
            }

            var duration     = new Duration(DateTime.UtcNow - TimeSpan.FromDays(MaxDurationForCorrelationLookupInDays), DateTime.UtcNow);
            var queryTracker = QueryStatTracker.CreateAndMarkQueryStart(ReaderConstants.CorrelatedEvents, eventInstanceId, queryParameters);
            var events       = new EventStoreReader()
                               .GetCorrelatedEvents(
                eventInstanceGuid,
                duration,
                CancellationToken.None)
                               .GetAwaiter()
                               .GetResult()
                               .ToArray();

            queryTracker.MarkQueryEnd(events.Count());

            writer.Write(new JsonSerializerHelper().SerializeObject(events.Take(MaxRecordsInResult).OrderBy(item => item.TimeStamp)));
        }
Beispiel #5
0
        private static void HandlePartitionsEvents(IResultWriter writer, string partitionIdString, QueryParametersWrapper queryParameters)
        {
            if (!ValidateStartAndEndTime(queryParameters.StartTimeUtc, queryParameters.EndTimeUtc))
            {
                OnUnsupportedUri(writer);
                return;
            }

            var partitionGuid = Guid.Empty;

            if (!string.IsNullOrWhiteSpace(partitionIdString))
            {
                if (!Guid.TryParse(partitionIdString, out partitionGuid))
                {
                    EventStoreLogger.Logger.LogWarning("HandlePartitionsEvents:: Partition ID : {0} Is not a valid Guid", partitionIdString);
                    OnUnsupportedUri(writer);
                    return;
                }
            }

            var queryTracker = QueryStatTracker.CreateAndMarkQueryStart(ReaderConstants.Partitions, partitionIdString, queryParameters);
            var events       = new EventStoreReader()
                               .GetPartitionEventsAsync(
                partitionGuid,
                new Duration(
                    queryParameters.StartTimeUtc,
                    queryParameters.EndTimeUtc),
                ConvertUserEventTypesToUnderlyingTypes(
                    EntityType.Partition,
                    queryParameters.EventsTypesFilter),
                CancellationToken.None)
                               .GetAwaiter()
                               .GetResult()
                               .ToArray();

            queryTracker.MarkQueryEnd(events.Count());

            writer.Write(new JsonSerializerHelper().SerializeObject(events.Take(MaxRecordsInResult).OrderBy(item => item.TimeStamp)));
        }
Beispiel #6
0
        private static void HandleClusterEvents(IResultWriter writer, QueryParametersWrapper queryParameters)
        {
            if (!ValidateStartAndEndTime(queryParameters.StartTimeUtc, queryParameters.EndTimeUtc))
            {
                OnUnsupportedUri(writer);
                return;
            }

            var events = new EventStoreReader()
                         .GetClusterEventsAsync(
                new Duration(
                    queryParameters.StartTimeUtc,
                    queryParameters.EndTimeUtc),
                ConvertUserEventTypesToUnderlyingTypes(
                    EntityType.Cluster,
                    queryParameters.EventsTypesFilter),
                CancellationToken.None)
                         .GetAwaiter()
                         .GetResult()
                         .ToArray();

            writer.Write(new JsonSerializerHelper().SerializeObject(events.Take(MaxRecordsInResult).OrderBy(item => item.TimeStamp)));
        }
 public HistoricalEmotivSessionReader(EventStoreReader reader)
 {
     this.reader = reader;
 }
Beispiel #8
0
        // partitionId will always have a value here.
        private static void HandleReplicasEvents(IResultWriter writer, string partitionIdString, string replicaIdString, QueryParametersWrapper queryParameters)
        {
            if (!ValidateStartAndEndTime(queryParameters.StartTimeUtc, queryParameters.EndTimeUtc))
            {
                OnUnsupportedUri(writer);
                return;
            }

            var partitionGuid = Guid.Empty;

            if (!string.IsNullOrWhiteSpace(partitionIdString))
            {
                if (!Guid.TryParse(partitionIdString, out partitionGuid))
                {
                    EventStoreLogger.Logger.LogWarning("HandleReplicaEvents:: Partition ID : {0} Is not a valid Guid", partitionIdString);
                    OnUnsupportedUri(writer);
                    return;
                }
            }

            // For replica events, Partition ID needs to be valid. So, verify that we have a valid ID Now.
            if (partitionGuid == Guid.Empty)
            {
                EventStoreLogger.Logger.LogWarning("HandleReplicaEvents:: Partition Guid Not Valid", string.IsNullOrEmpty(partitionIdString) ? "Empty" : partitionIdString);
                OnUnsupportedUri(writer);
                return;
            }

            long?replicaId = null;

            if (!string.IsNullOrWhiteSpace(replicaIdString))
            {
                long id = 0;
                if (!long.TryParse(replicaIdString, out id))
                {
                    EventStoreLogger.Logger.LogWarning("HandleReplicaEvents:: ReplicaId : {0} Is Invalid", replicaIdString);
                    OnUnsupportedUri(writer);
                    return;
                }

                replicaId = id;
            }

            var queryTracker = QueryStatTracker.CreateAndMarkQueryStart(ReaderConstants.Replicas, string.Format("{0}:{1}", partitionGuid, replicaId), queryParameters);
            var events       = new EventStoreReader()
                               .GetReplicaEventsAsync(
                partitionGuid,
                replicaId,
                new Duration(
                    queryParameters.StartTimeUtc,
                    queryParameters.EndTimeUtc),
                ConvertUserEventTypesToUnderlyingTypes(
                    EntityType.Replica,
                    queryParameters.EventsTypesFilter),
                CancellationToken.None)
                               .GetAwaiter()
                               .GetResult()
                               .ToArray();

            queryTracker.MarkQueryEnd(events.Count());

            writer.Write(new JsonSerializerHelper().SerializeObject(events.Take(MaxRecordsInResult).OrderBy(item => item.TimeStamp)));
        }
 internal EventStoreRuntime(EventStoreReader eventReader, bool testMode)
 {
     Assert.IsNotEmptyOrNull("eventReader", "eventReader != null");
     this.EventStoreReader = eventReader;
     this.TestMode         = testMode;
 }
 internal EventStoreRuntime(EventStoreReader eventReader) : this(eventReader, false)
 {
 }
        public async Task Test1()
        {
            EventStoreReader reader = await GetSut();

            bool result = await reader.ExistsStreamAsync("aa");
        }
 public EmotivSessionsController(EventStoreReader reader)
 {
     this.reader = reader;
 }