feat(tvix): Introduce build event streams in worker protocol
Introduces a new `BuildEvent` proto type which is streamed in response to calls that trigger builds of derivations. This type can currently supply build statuses, log lines and information about builds starting. This is in preparation for threading build logs through the processes. Since we have nowhere to send the logs (yet), a null sink is used instead. Co-authored-by: Griffin Smith <grfn@gws.fyi> Change-Id: If7332337b89506c7e404cd20174acdaa1a3be4e8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1793 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: kanepyork <rikingcoding@gmail.com>
This commit is contained in:
		
							parent
							
								
									883de9b8d7
								
							
						
					
					
						commit
						19e874a985
					
				
					 5 changed files with 92 additions and 25 deletions
				
			
		| 
						 | 
				
			
			@ -29,7 +29,6 @@ namespace nix::daemon {
 | 
			
		|||
 | 
			
		||||
using ::google::protobuf::util::TimeUtil;
 | 
			
		||||
using ::grpc::Status;
 | 
			
		||||
using ::nix::proto::BuildStatus;
 | 
			
		||||
using ::nix::proto::PathInfo;
 | 
			
		||||
using ::nix::proto::StorePath;
 | 
			
		||||
using ::nix::proto::StorePaths;
 | 
			
		||||
| 
						 | 
				
			
			@ -271,9 +270,9 @@ class WorkerServiceImpl final : public WorkerService::Service {
 | 
			
		|||
        __FUNCTION__);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Status BuildPaths(grpc::ServerContext*,
 | 
			
		||||
                    const nix::proto::BuildPathsRequest* request,
 | 
			
		||||
                    google::protobuf::Empty*) override {
 | 
			
		||||
  Status BuildPaths(
 | 
			
		||||
      grpc::ServerContext*, const nix::proto::BuildPathsRequest* request,
 | 
			
		||||
      grpc::ServerWriter<nix::proto::BuildEvent>* /* writer */) override {
 | 
			
		||||
    return HandleExceptions(
 | 
			
		||||
        [&]() -> Status {
 | 
			
		||||
          PathSet drvs;
 | 
			
		||||
| 
						 | 
				
			
			@ -612,7 +611,7 @@ class WorkerServiceImpl final : public WorkerService::Service {
 | 
			
		|||
  Status BuildDerivation(
 | 
			
		||||
      grpc::ServerContext* context,
 | 
			
		||||
      const nix::proto::BuildDerivationRequest* request,
 | 
			
		||||
      nix::proto::BuildDerivationResponse* response) override {
 | 
			
		||||
      grpc::ServerWriter<nix::proto::BuildEvent>* writer) override {
 | 
			
		||||
    return HandleExceptions(
 | 
			
		||||
        [&]() -> Status {
 | 
			
		||||
          auto drv_path = request->drv_path().path();
 | 
			
		||||
| 
						 | 
				
			
			@ -625,11 +624,19 @@ class WorkerServiceImpl final : public WorkerService::Service {
 | 
			
		|||
            return Status(grpc::StatusCode::INTERNAL, "Invalid build mode");
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          auto res = store_->buildDerivation(drv_path, drv, *build_mode);
 | 
			
		||||
          BuildResult res = store_->buildDerivation(drv_path, drv, *build_mode);
 | 
			
		||||
 | 
			
		||||
          response->set_status(res.status_to_proto());
 | 
			
		||||
          response->set_error_message(res.errorMsg);
 | 
			
		||||
          proto::BuildResult proto_res{};
 | 
			
		||||
          proto_res.set_status(res.status_to_proto());
 | 
			
		||||
 | 
			
		||||
          if (!res.errorMsg.empty()) {
 | 
			
		||||
            proto_res.set_msg(res.errorMsg);
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          proto::BuildEvent event{};
 | 
			
		||||
          *event.mutable_result() = proto_res;
 | 
			
		||||
 | 
			
		||||
          writer->Write(event);
 | 
			
		||||
          return Status::OK;
 | 
			
		||||
        },
 | 
			
		||||
        __FUNCTION__);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue