public static IAppBuilder UseLiquidProjections(this IAppBuilder appBuilder, IProjectionStats stats) { appBuilder.Map("/projectionStats", a => a.UseNancy(new NancyOptions { Bootstrapper = new CustomNancyBootstrapper(stats) })); return(appBuilder); }
public StatisticsModule(IProjectionStats stats, IResourceLinker resourceLinker) { Get("/", args => { var results = stats.OrderBy(p => p.ProjectorId).Select(p => new ProjectorSummary { ProjectorId = p.ProjectorId, LastCheckpoint = p.LastCheckpoint.Checkpoint, LastCheckpointUpdatedUtc = p.LastCheckpoint.TimestampUtc, Url = Context.Request.Url + $"/{p.ProjectorId}" }); return(results); }, null, "GetAll"); Get("/{id}", args => { string id = args.Id; return(new { ProjectorId = id, LastCheckpoint = stats.Get(id).LastCheckpoint.Checkpoint, LastCheckpointUpdatedUtc = stats.Get(id).LastCheckpoint.TimestampUtc, Properties = stats.Get(id).GetProperties().Select(p => new ProjectorProperty { Key = p.Key, Value = p.Value.Value, LastUpdatedUtc = p.Value.TimestampUtc }), EventsUrl = resourceLinker.BuildAbsoluteUri(Context, "GetEvents", new { args.id }).ToString() }); }, null, "GetSpecific"); Get("/{id}/events", args => { string id = args.Id; return(new ProjectorEventCollection { ProjectorId = id, Events = stats.Get(id).GetEvents().Select(@event => new ProjectorEvent { Body = @event.Body, TimestampUtc = @event.TimestampUtc }) }); }, null, "GetEvents"); Get("/{id}/eta/{targetCheckpoint}", args => { string id = args.Id; TimeSpan?eta = stats.GetTimeToReach(id, args.targetCheckpoint); return(new { Eta = eta }); }, null, "GetEta"); }
public CustomNancyBootstrapper(IProjectionStats stats) { this.stats = stats; }