Skip to content

Commit f179b29

Browse files
committed
Document the worker protocol in the example
1 parent bbf8a85 commit f179b29

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

examples/persistent_worker/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,41 @@ stderr for root//:demo-7 (demo):
9999
Bazel persistent worker ...
100100
...
101101
```
102+
103+
## Protocol
104+
105+
### Starlark
106+
107+
A Buck2 persistent worker is created by a rule that emits the
108+
`WorkerInfo` provider. Setting `remote = True` on this provider
109+
indicates that this worker is remote execution capable.
110+
111+
Buck2 actions indicate that they can utilize a persistent worker by
112+
setting the `exe` parameter to `ctx.actions.run` to
113+
`WorkerRunInfo(worker, exe)`, where `worker` is a `WorkerInfo` provider,
114+
and `exe` defines the fallback executable for non persistent-worker
115+
execution.
116+
117+
Buck2 actions that want to utilize a remote persistent worker must pass
118+
command-line arguments in an argument file specified as `@argfile`,
119+
`-flagfile=argfile`, or `--flagfile=argfile` on the command-line.
120+
121+
### Local Persistent Worker
122+
123+
A locally executed Buck2 persistent worker falls under the [Buck2
124+
persistent worker protocol](./proto/buck2): It is started and managed by
125+
Buck2 and passed a file path in the `WORKER_SOCKET` environment variable
126+
where it should create a gRPC Unix domain socket to serve worker
127+
requests over. Multiple requests may be sent in parallel and expected to
128+
be served at the same time depending on the `concurrency` attribute of
129+
the `WorkerInfo` provider.
130+
131+
### Remote Persistent Worker
132+
133+
A remotely executed Buck2 persistent worker falls under the [Bazel
134+
persistent worker protocol](./proto/bazel): It is started and managed by
135+
the remote execution system. Work requests are sent as length prefixed
136+
protobuf objects to the standard input of the worker process. Work
137+
responses are expected as length prefixed protobuf objects on the
138+
standard output of the worker process. The worker process may not use
139+
standard output for anything else.

0 commit comments

Comments
 (0)