private static void Display <T>(IStreamable <Empty, T> stream) { stream.ToStreamEventObservable().ForEachAsync( r => { switch (r.Kind) { case StreamEventKind.Interval: Console.WriteLine($"INTERVAL: " + $"start={new DateTime(r.StartTime)}, end={new DateTime(r.EndTime)}, payload={r.Payload}"); break; case StreamEventKind.Start: Console.WriteLine($"START EDGE: " + $"start={new DateTime(r.StartTime)}, payload={r.Payload}"); break; case StreamEventKind.End: Console.WriteLine($"END EDGE: " + $"end={new DateTime(r.EndTime)}, original start={new DateTime(r.StartTime)}, payload={r.Payload}"); break; case StreamEventKind.Punctuation: Console.WriteLine("PUNCTUATION: start={0}", new DateTime(r.StartTime)); break; } }); // .Wait(); }
public static void SubscribeToConsole <TP>(this IStreamable <Empty, TP> stream) { stream.ToStreamEventObservable() .Where(e => e.IsData).ForEachAsync(x => Console.WriteLine("Time: {0} Payload: {1}", x.StartTime, x.Payload)).Wait(); Console.WriteLine(); }
private static void Display <T>(IStreamable <Empty, T> stream) { stream.ToStreamEventObservable().ForEachAsync( r => { switch (r.Kind) { case StreamEventKind.Interval: Console.WriteLine( "INTERVAL: start={0}, end={1}, payload={2}", new DateTime(r.SyncTime), new DateTime(r.OtherTime), r.Payload); break; case StreamEventKind.Start: Console.WriteLine("START EDGE: start={0}, payload={1}", new DateTime(r.SyncTime), r.Payload); break; case StreamEventKind.End: Console.WriteLine( "END EDGE: end={0}, original start={1}, payload={2}", new DateTime(r.SyncTime), new DateTime(r.OtherTime), r.Payload); break; case StreamEventKind.Punctuation: Console.WriteLine("PUNCTUATION: start={0}", new DateTime(r.SyncTime)); break; } }).Wait(); }
/// <summary> /// Exports a streamable as an observable of events. Produces events that are sync time ordered. /// </summary> /// <typeparam name="TKey"></typeparam> /// <typeparam name="TPayload"></typeparam> /// <param name="stream"></param> /// <param name="reshapingPolicy">Policy that specifies whether and how events are reshaped at egress. Default passes events through unmodified.</param> /// <returns></returns> public static IObservable <PartitionedStreamEvent <TKey, TPayload> > ToStreamEventObservable <TKey, TPayload>( this IStreamable <PartitionKey <TKey>, TPayload> stream, ReshapingPolicy reshapingPolicy = ReshapingPolicy.None) { Invariant.IsNotNull(stream, nameof(stream)); return(stream.ToStreamEventObservable( null, Guid.NewGuid().ToString(), reshapingPolicy)); }
/// <summary> /// Exports a streamable as an observable of events. Produces events that are sync time ordered. /// </summary> /// <typeparam name="TPayload"></typeparam> /// <param name="container">The query container to which an egress point is being added.</param> /// <param name="identifier">A string that can uniquely identify the point of egress in the query.</param> /// <param name="stream"></param> /// <param name="reshapingPolicy">Policy that specifies whether and how events are reshaped at egress. Default passes events through unmodified.</param> /// <returns></returns> public static IObservable <StreamEvent <TPayload> > RegisterOutput <TPayload>( this QueryContainer container, IStreamable <Empty, TPayload> stream, ReshapingPolicy reshapingPolicy = ReshapingPolicy.None, string identifier = null) { Invariant.IsNotNull(stream, nameof(stream)); return(stream.ToStreamEventObservable( container, identifier ?? Guid.NewGuid().ToString(), reshapingPolicy)); }
public static StreamEvent <TPayload>[] ToStreamEventArray <TPayload>(this IStreamable <Empty, TPayload> input) { Invariant.IsNotNull(input, "input"); return(input.ToStreamEventObservable().ToEnumerable().ToArray()); }