public AggregateQueryRunner(AggregateQuery query) { if (query.Streak == null) { throw new Exception("Streak cannot be null!"); } if (query.Init == null) { throw new Exception("Init function cannot be null!"); } if (query.Aggregate == null) { throw new Exception("Aggregate function cannot be null!"); } Query = query; //Compile lambdas var init = LambdaCompiler.CreateInit(query.Init); _aggregate = LambdaCompiler.CreateLambda(query.Aggregate); //Create reader streak _streak = new Streak.Core.Streak(query.Streak); //Initialize state _state = init(); //Run _tokenSource = new CancellationTokenSource(); Run(_tokenSource.Token); }
public void AddQuery(AggregateQuery query) { lock (_sync) { var runner = new AggregateQueryRunner(query); _queries.Add(runner); var e = new Event { Data = JsonConvert.SerializeObject(query), Meta = "", Type = "AddAggregateQuery" }; _streak.Save(new[] { e }); } }