1*ae21b2b4SYike Zhang# remote-apis 2*ae21b2b4SYike Zhang 3*ae21b2b4SYike ZhangThis repository contains a collection of APIs which work together to enable 4*ae21b2b4SYike Zhanglarge scale distributed execution and caching on source code and other inputs. 5*ae21b2b4SYike ZhangIt describes how to upload inputs, request the execution, monitor for results, 6*ae21b2b4SYike Zhangand cache those results. It's overall aim is to enable large scale parallel executions 7*ae21b2b4SYike Zhangthat wouldn't be feasible on a single system, while minimizing the amount of uploads 8*ae21b2b4SYike Zhangand executions needed by storing data in a content-addressable format and caching results. 9*ae21b2b4SYike Zhang 10*ae21b2b4SYike Zhang### [Remote Execution API](build/bazel/remote/execution/v2/remote_execution.proto) 11*ae21b2b4SYike Zhang 12*ae21b2b4SYike ZhangThe Remote Execution API is an API that, at its most general, allows clients to request 13*ae21b2b4SYike Zhangexecution of binaries on a remote system. It is intended primarily for use by build systems, 14*ae21b2b4SYike Zhangsuch as [Bazel](bazel.build), to distribute build and test actions through a worker pool, 15*ae21b2b4SYike Zhangand also provide a central cache of build results. This allows builds to execute 16*ae21b2b4SYike Zhangfaster, both by reusing results already built by other clients and by allowing many 17*ae21b2b4SYike Zhangactions to be executed in parallel, in excess of the resource limits of the machine 18*ae21b2b4SYike Zhangrunning the build. 19*ae21b2b4SYike Zhang 20*ae21b2b4SYike Zhang### [Remote Asset API](build/bazel/remote/asset/v1/remote_asset.proto) 21*ae21b2b4SYike Zhang 22*ae21b2b4SYike ZhangThe Remote Asset API is an API to associate Qualifiers and URIs to Digests stored in 23*ae21b2b4SYike ZhangContent Addressable Storage. It is primary intended to allow clients to use semantically 24*ae21b2b4SYike Zhangrelevant identifiers, such as a git repository or tarball location, to get the corresponding 25*ae21b2b4SYike ZhangDigest. This mapping may be pushed by a client directly, or dynamically resolved and added 26*ae21b2b4SYike Zhangto CAS by the asset server when fetched by a client. 27*ae21b2b4SYike Zhang 28*ae21b2b4SYike Zhang### [Remote Logstream API](build/bazel/remote/logstream/v1/remote_logstream.proto) 29*ae21b2b4SYike Zhang 30*ae21b2b4SYike ZhangThe Remote Logstream API is an API supporting ordered reads and writes of `LogStream` 31*ae21b2b4SYike Zhangresources. It is intented primarily for streaming the stdout and stderr of ongoing Action 32*ae21b2b4SYike Zhangexecutions, enabling clients to view them while the Action is executing instead of waiting 33*ae21b2b4SYike Zhangfor it's completion. 34*ae21b2b4SYike Zhang 35*ae21b2b4SYike Zhang## API users 36*ae21b2b4SYike Zhang 37*ae21b2b4SYike ZhangThere are a number of clients and services using these APIs, they are listed 38*ae21b2b4SYike Zhangbelow. 39*ae21b2b4SYike Zhang 40*ae21b2b4SYike Zhang### Clients 41*ae21b2b4SYike ZhangThese tools use the Remote Execution API to distribute builds to workers. 42*ae21b2b4SYike Zhang 43*ae21b2b4SYike Zhang* [Bazel](https://bazel.build) 44*ae21b2b4SYike Zhang* [Buck2](https://github.com/facebook/buck2) 45*ae21b2b4SYike Zhang* [BuildStream](https://buildstream.build/) 46*ae21b2b4SYike Zhang* [Goma Server](https://chromium.googlesource.com/infra/goma/server/) 47*ae21b2b4SYike Zhang* [Justbuild](https://github.com/just-buildsystem/justbuild) (via `--compatible`) 48*ae21b2b4SYike Zhang* [Pants](https://www.pantsbuild.org) 49*ae21b2b4SYike Zhang* [Please](https://please.build) 50*ae21b2b4SYike Zhang* [Recc](https://gitlab.com/bloomberg/recc) 51*ae21b2b4SYike Zhang* [Reclient](https://github.com/bazelbuild/reclient) 52*ae21b2b4SYike Zhang* [Siso](https://chromium.googlesource.com/infra/infra/+/refs/heads/main/go/src/infra/build/siso/) 53*ae21b2b4SYike Zhang 54*ae21b2b4SYike Zhang### Servers 55*ae21b2b4SYike ZhangThese applications implement the Remote Execution API to serve build requests 56*ae21b2b4SYike Zhangfrom the clients above. 57*ae21b2b4SYike Zhang 58*ae21b2b4SYike Zhang* [bazel-remote](https://github.com/buchgr/bazel-remote) (open source, cache only) 59*ae21b2b4SYike Zhang* [Buildbarn](https://github.com/buildbarn) (open source) 60*ae21b2b4SYike Zhang* [BuildBuddy](https://www.buildbuddy.io/) (commercial & open source) 61*ae21b2b4SYike Zhang* [Buildfarm](https://github.com/bazelbuild/bazel-buildfarm) (open source) 62*ae21b2b4SYike Zhang* [BuildGrid](https://buildgrid.build/) (open source) 63*ae21b2b4SYike Zhang* [EngFlow](https://www.engflow.com/) (commercial) 64*ae21b2b4SYike Zhang* [Flare Build Execution](https://flare.build/products/flare-build-execution) (commercial) 65*ae21b2b4SYike Zhang* [Justbuild](https://github.com/just-buildsystem/justbuild/blob/master/doc/tutorial/just-execute.org) (via `--compatible`, open source) 66*ae21b2b4SYike Zhang* [Kajiya](https://chromium.googlesource.com/infra/infra/+/refs/heads/main/go/src/infra/build/kajiya/) (open source) 67*ae21b2b4SYike Zhang* [NativeLink](https://github.com/TraceMachina/nativelink) (open source) 68*ae21b2b4SYike Zhang* [Scoot](https://github.com/twitter/scoot) (open source) 69*ae21b2b4SYike Zhang 70*ae21b2b4SYike Zhang### Workers 71*ae21b2b4SYike ZhangServers generally distribute work to a fleet of workers. 72*ae21b2b4SYike ZhangThe [Remote Worker API](https://docs.google.com/document/d/1s_AzRRD2mdyktKUj2HWBn99rMg_3tcPvdjx3MPbFidU) 73*ae21b2b4SYike Zhangdefines a generic protocol for worker and server communication, although, 74*ae21b2b4SYike Zhangthis API is considered too heavyweight for most use-cases. Because of that, 75*ae21b2b4SYike Zhangmany implementations have designed their own protocols. Links to these APIs 76*ae21b2b4SYike Zhangare provided as a reference below. 77*ae21b2b4SYike Zhang*Adhering to any one of these protocols is not a requirement.* 78*ae21b2b4SYike Zhang 79*ae21b2b4SYike Zhang* [Buildfarm Operation Queues](https://bazelbuild.github.io/bazel-buildfarm/docs/architecture/queues/) 80*ae21b2b4SYike Zhang * Uses sets of queues for managing different payload requirements. 81*ae21b2b4SYike Zhang* [Buildbarn Remote Worker](https://github.com/buildbarn/bb-remote-execution/blob/master/pkg/proto/remoteworker/remoteworker.proto) 82*ae21b2b4SYike Zhang * Uses a custom protocol for workers to connect to a scheduler and receive instructions. 83*ae21b2b4SYike Zhang* [BuildGrid Bots](https://buildgrid.build/developer/data_model.html#rwapi) 84*ae21b2b4SYike Zhang * A server implementation of the Remote Workers API. 85*ae21b2b4SYike Zhang* [Buildbox Worker](https://gitlab.com/BuildGrid/buildbox/buildbox-worker) 86*ae21b2b4SYike Zhang * A worker implementation of the Remote Workers API. 87*ae21b2b4SYike Zhang 88*ae21b2b4SYike Zhang## API Community 89*ae21b2b4SYike Zhang 90*ae21b2b4SYike ZhangThe [Remote Execution APIs 91*ae21b2b4SYike Zhanggroup](https://groups.google.com/forum/#!forum/remote-execution-apis) hosts 92*ae21b2b4SYike Zhangdiscussions related to the APIs in this repository. 93*ae21b2b4SYike Zhang 94*ae21b2b4SYike ZhangInterested parties meet monthly via VC to discuss issues related to the APIs, 95*ae21b2b4SYike Zhangand several contributors have organized occasional meetups, hack-a-thons, and 96*ae21b2b4SYike Zhangsummits. Joining the email discussion group will automatically add you to the 97*ae21b2b4SYike ZhangGoogle Calendar invite for the monthly meeting. 98*ae21b2b4SYike Zhang 99*ae21b2b4SYike Zhang## Dependencies 100*ae21b2b4SYike Zhang 101*ae21b2b4SYike ZhangThe APIs in this repository refer to several general-purpose APIs published by 102*ae21b2b4SYike ZhangGoogle in the [Google APIs 103*ae21b2b4SYike Zhangrepository](https://github.com/googleapis/googleapis). You will need to refer to 104*ae21b2b4SYike Zhangpackages from that repository in order to generate code using this API. If you 105*ae21b2b4SYike Zhangbuild the repository using the included `BUILD` files, Bazel will fetch the 106*ae21b2b4SYike Zhangprotobuf compiler and googleapis automatically. 107*ae21b2b4SYike Zhang 108*ae21b2b4SYike Zhang## Using the APIs 109*ae21b2b4SYike Zhang 110*ae21b2b4SYike ZhangThe repository contains `BUILD` files to build the protobuf library with 111*ae21b2b4SYike Zhang[Bazel](https://bazel.build/). If you wish to use them with your own project in 112*ae21b2b4SYike ZhangBazel, you will possibly want to declare `cc_proto_library`, 113*ae21b2b4SYike Zhang`java_proto_library`, etc. rules that depend on them. 114*ae21b2b4SYike Zhang 115*ae21b2b4SYike ZhangOther build systems will have to run protoc on the protobuf files, and link in 116*ae21b2b4SYike Zhangthe googleapis and well-known proto types, manually. 117*ae21b2b4SYike Zhang 118*ae21b2b4SYike Zhang### Go (for non-Bazel build systems) 119*ae21b2b4SYike Zhang 120*ae21b2b4SYike ZhangThis repository contains the generated Go code for interacting with the API via 121*ae21b2b4SYike ZhanggRPC. Get it with: 122*ae21b2b4SYike Zhang 123*ae21b2b4SYike Zhang``` 124*ae21b2b4SYike Zhanggo get github.com/bazelbuild/remote-apis 125*ae21b2b4SYike Zhang``` 126*ae21b2b4SYike Zhang 127*ae21b2b4SYike ZhangImport it with, for example: 128*ae21b2b4SYike Zhang 129*ae21b2b4SYike Zhang``` 130*ae21b2b4SYike Zhangrepb "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2" 131*ae21b2b4SYike Zhang``` 132*ae21b2b4SYike Zhang 133*ae21b2b4SYike Zhang## Development 134*ae21b2b4SYike Zhang 135*ae21b2b4SYike ZhangEnable the git hooks to automatically generate Go proto code on commit: 136*ae21b2b4SYike Zhang 137*ae21b2b4SYike Zhang``` 138*ae21b2b4SYike Zhanggit config core.hooksPath hooks/ 139*ae21b2b4SYike Zhang``` 140*ae21b2b4SYike Zhang 141*ae21b2b4SYike ZhangThis is a local setting, so applies only to this repository. 142