private void ProcessRequest(BuildRequest obj) { var(idObservable, data) = obj; idObservable .Take(1) .ObserveOnSelf() .Subscribe(operationId => { Context.Sender.Tell(BuildMessage.GatherData(operationId)); _remaining = 0; _fail = false; var toBuild = new List <PreparedBuild>(data.Projects.Count); toBuild.AddRange(from project in data.Projects let path = data.FindProjectPath(project) where !string.IsNullOrWhiteSpace(path) select new PreparedBuild(data.BuildInfo, project, data, operationId, path)); if (toBuild.Count == 0) { Context.Sender.Tell(BuildMessage.NoData(operationId)); return; } var agent = 1; foreach (var preparedBuild in toBuild) { _remaining++; Context.GetOrAdd <BuildAgent>("Agent-" + agent).Forward(preparedBuild); agent++; } }); }
private Maybe <AgentCompled> OnBuild(Maybe <PreparedBuild> mayBuild) { var agentName = Context.Self.Path.Name + ": "; return(MatchMay( from build in mayBuild select Try(() => from step1 in MayTell(Context.Sender, BuildMessage.GatherData(build.Operation, agentName)) from data in GetData(build) from step2 in MayTell(Context.Sender, BuildMessage.GenerateLangFiles(build.Operation, agentName)) from a in GenerateJson(data, build.TargetPath) from step3 in MayTell(Context.Sender, BuildMessage.GenerateCsFiles(build.Operation, agentName)) from b in GenerateCode(data, build.TargetPath) from final in MayTell(Context.Sender, BuildMessage.AgentCompled(build.Operation, agentName)) select new AgentCompled(false, Maybe <Exception> .Nothing, build.Operation)), e => May(new AgentCompled(true, May(e), mayBuild.Value.Operation)))); }
private static AgentCompled OnBuild(PreparedBuild build) { try { var agentName = Context.Self.Path.Name + ": "; Context.Sender.Tell(BuildMessage.GatherData(build.Operation, agentName)); var data = GetData(build); Context.Sender.Tell(BuildMessage.GenerateLangFiles(build.Operation, agentName)); GenerateJson(data, build.TargetPath); Context.Sender.Tell(BuildMessage.GenerateCsFiles(build.Operation, agentName)); GenerateCode(data, build.TargetPath); Context.Sender.Tell(BuildMessage.AgentCompled(build.Operation, agentName)); return(new AgentCompled(false, null, build.Operation)); } catch (Exception e) { return(new AgentCompled(true, e, build.Operation)); } }