public async Task <CalculationPack> Create(CalculationPack calc) { //await _calculationPacks. InsertOneAsync(calc); var result = _cache.GetOrAdd(calc.Id, () => CreatePack(calc)); return(calc); }
public async Task ProduceResultAsync(CalculationPack data) { var msg = new Message <int, CalculationPack>() { Key = data.Id, Value = data }; await _producer.ProduceAsync("results", msg); }
public async Task <IActionResult> CreateSinglePack(CalculationPack calc) { var result = await _calculationPackService.Create(calc); if (result != null) { return(Ok(result)); } return(NotFound()); }
public async Task <int> GeneratePacks(int numOfCalcs, int numOfUnits) { var result = new List <CalculationPack>(); for (int i = 0; i < numOfCalcs; i++) { Random rand = new Random(); var id = rand.Next(); var pack = new CalculationPack() { Id = id, Count = numOfCalcs, EqId = 1, Data = GenerateUnits(numOfUnits, id) }; result.Add(pack); } await _calculationPackProducer.GeneratePacks(result); return(numOfCalcs); }
public async Task <CalculationPack> Save(CalculationPack pack) { await _calculationPacks.InsertOneAsync(pack); return(pack); }
public async Task <CalculationPack> Create(CalculationPack calc) { return(await _calculationPackRepository.Create(calc)); }
private CalculationPack CreatePack(CalculationPack calc) { _calculationPacks.InsertOneAsync(calc); return(calc); }