public VehicleService(IRepository <string, VehicleData, VehicleFilter> repository, ICustomerService customerService, IServiceBus bus, IStatusCache statusCache, ILogger <VehicleService> logger) { _repository = repository; _statusCache = statusCache; _customerService = customerService; _bus = bus; _logger = logger; }
public static Task SubscribeEvents(this IServiceBusListenerFactory listener, IStatusCache statusCache, VehicleSubscription vehicleSubscription) => listener.Create() .SubscribeVehicleInfo(t => statusCache.Update(t.Id, t)) .SubscribeVehicleInfo(vehicleSubscription.Send);
public static async Task <Dictionary <string, VehicleStatusMessage> > ExtractStatuses(this IStatusCache cache, IEnumerable <VehicleData> fromStorage) { var statuses = new Dictionary <string, VehicleStatusMessage>(); foreach (var vehicle in fromStorage) { var vehicleInfo = await cache.Get(vehicle.Id); statuses.Add(vehicle.Id, vehicleInfo); } return(statuses); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime lifetime, IServiceBusListenerFactory listenerFactory, IStatusCache statusCache, VehicleSubscription vehicleSubscription) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAuthentication(); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"client-build")), RequestPath = new PathString(@"/client-build") }); app.UseSignalR(routes => routes.MapHub <VehicleHub>("/vehicleHub")); app.UseMvc(); lifetime.ApplicationStarted.Register(() => listenerFactory.SubscribeEvents(statusCache, vehicleSubscription)); }