-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start using official Bazel worker helper.
This helper provides additional features like GC and worker multiplexing - though they are not yet enabled in this CL. CL is temporarily forking the files until bazel_worker_java could be added as a dep for repo: bazelbuild/bazel-worker-api#10 PiperOrigin-RevId: 733024990
- Loading branch information
1 parent
73c7c3a
commit a8accf3
Showing
5 changed files
with
898 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
transpiler/java/com/google/j2cl/common/bazel/ProtoWorkerMessageProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2020 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package com.google.j2cl.common.bazel; | ||
|
||
import com.google.devtools.build.lib.worker.WorkerProtocol.WorkRequest; | ||
import com.google.devtools.build.lib.worker.WorkerProtocol.WorkResponse; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
|
||
// TODO(goktug): Remove this class after https://github.com/bazelbuild/bazel-worker-api/issues/10 | ||
|
||
/** Implementation of the Worker Protocol using Proto to communicate with Bazel. */ | ||
final class ProtoWorkerMessageProcessor implements WorkRequestHandler.WorkerMessageProcessor { | ||
|
||
/** This worker's stdin. */ | ||
private final InputStream stdin; | ||
|
||
/** This worker's stdout. Only {@link WorkRequest}s should be written here. */ | ||
private final OutputStream stdout; | ||
|
||
/** Constructs a {@link WorkRequestHandler} that reads and writes Protocol Buffers. */ | ||
public ProtoWorkerMessageProcessor(InputStream stdin, OutputStream stdout) { | ||
this.stdin = stdin; | ||
this.stdout = stdout; | ||
} | ||
|
||
@Override | ||
public WorkRequest readWorkRequest() throws IOException { | ||
return WorkRequest.parseDelimitedFrom(stdin); | ||
} | ||
|
||
@Override | ||
public void writeWorkResponse(WorkResponse workResponse) throws IOException { | ||
try { | ||
workResponse.writeDelimitedTo(stdout); | ||
} finally { | ||
stdout.flush(); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() {} | ||
} |
Oops, something went wrong.