Add anthropics/buffa and anthropics/connect-rust plugins#2334
Conversation
61b03f3 to
eca199a
Compare
eca199a to
f42cc7a
Compare
f42cc7a to
92259e7
Compare
|
changed to crate ref instead of github ref 👍 |
92259e7 to
314f1da
Compare
314f1da to
b60cff4
Compare
| # The plugin accepts `extern_path=.=<rust_path>` (or the shorthand | ||
| # `buffa_module=<rust_path>`) to tell it where the buffa-generated message | ||
| # types live. BSR should inject this based on the buffa dep's SDK crate | ||
| # name, same as tonic receives extern_path for its prost dep. Leaving | ||
| # opts empty here; please advise if an explicit entry is needed. | ||
| opts: [] |
There was a problem hiding this comment.
should be fine to leave this empty, and the BSR will figure out extern_path settings using the prost syntax 👍.
| # https://github.com/anthropics/connect-rust/blob/v0.3.2/connectrpc/Cargo.toml | ||
| - name: "connectrpc" | ||
| req: "0.3.2" | ||
| default_features: true |
There was a problem hiding this comment.
silly non-expert-in-rust question: I see the default features; those don't include the tls feature, but is that just something that is "enabled" by having the various "deps" in the sub-features installed? (Mostly trying to confirm that someone consuming this generated SDK could still use the TLS features.)
There was a problem hiding this comment.
[claude code] Yes — Cargo features are additive and unified per-crate across the dependency graph. The generated SDK crate only needs connectrpc's default features for the generated code to compile, so that's all it declares. A consumer who wants TLS adds their own direct dependency in their application's Cargo.toml:
connectrpc = { version = "0.4", features = ["tls"] }Cargo then compiles connectrpc once with the union of features requested by both the SDK crate and the application, so tls (and client-tls / server-tls / any other optional feature) is fully available. Same model the tonic SDK crates use — the SDK doesn't gate runtime features.
b60cff4 to
114550b
Compare
|
[claude code] Updated to I haven't been able to check in |
1bbdd79 to
85561d7
Compare
|
[claude code] Pushed an update — Summary of changes since the last push:
The "Open question: extern_path injection — |
Adds two new plugins under the anthropics top-level org for Rust protobuf and ConnectRPC code generation. protoc-gen-buffa (v0.5.2) generates Rust message types using buffa, a zero-copy Protobuf implementation with editions support, no_std compatibility, and proto3 JSON mapping. With file_per_package=true it emits one <dotted.package>.rs per proto package, matching the prost/tonic filename convention the BSR Rust SDK lib.rs synthesis expects. protoc-gen-connect-rust (v0.4.2) generates ConnectRPC service stubs only — server traits, typed clients, monomorphic dispatchers — and declares buf.build/anthropics/buffa as a plugin dep for message types. Generated stubs reference message types via absolute Rust paths configured with extern_path, which the BSR injects from the deps: chain at SDK build time. The standalone test harness has no dep chain, so a testOverrideOptions entry passes a placeholder extern_path=.=crate catch-all — the same pattern neoeinstein-prost-crate (no_features) and neoeinstein-tonic (no_include) use to make isolated test runs succeed without affecting production opts. The connect-rust SDK crate depends on buffa-types (with the json feature) so service stubs whose request/response is a well-known type can reference ::buffa_types::google::protobuf::... and so connectrpc's Router bounds (Message + Serialize + DeserializeOwned) are satisfied for the Connect protocol's JSON codec.
85561d7 to
9c75f5b
Compare
Adds the
protoc-gen-buffaandprotoc-gen-connect-rustplugins for Rust protobuf and ConnectRPC code generation, under the new top-levelanthropicsorg as requested in earlier review.This PR contains both plugins, so it can land on its own. (It was originally stacked on #2333, which adds
anthropics/buffaalone — #2333 is now superseded by this PR.)buffa
buffa is a zero-copy Rust Protobuf implementation with:
&str/&[u8]field access without owned allocationCrates on crates.io:
buffa,buffa-types,protoc-gen-buffa.protoc-gen-buffagenerates message types. Withfile_per_package=true(set inopts), it emits one<dotted.package>.rsfile per proto package:foo/v1/bar.protoandfoo/v1/baz.protoboth land infoo.v1.rs. No subdirectories, nomod.rs. This matches the prost/tonic filename convention the BSR Rust SDKlib.rssynthesis already understands.connect-rust
connect-rust is a Tower-based Rust implementation of the ConnectRPC protocol:
request.nameis a&strborrow into the decoded bufferCrates on crates.io:
connectrpc,connectrpc-codegen,connectrpc-build.protoc-gen-connect-rustemits service stubs only - server traits, typed clients, monomorphic dispatchers. Message types come frombuf.build/anthropics/buffa(declared indeps:). Generated stubs reference message types via absolute Rust paths configured withextern_path. It also takesfile_per_package, mirroring theanthropics/buffaopt.Dockerfile note: the
protoc-gen-connect-rustbinary is a[[bin]]target inside theconnectrpc-codegencrate, socargo install connectrpc-codegenis what produces it.extern_path handling
protoc-gen-connect-rustneeds anextern_path=.=<rust_path>(or shorthandbuffa_module=<rust_path>) catch-all so it knows where the buffa-generated message types live. Per @stefanvanburen's review,opts:is left as just[file_per_package]— the BSR injectsextern_pathfrom thedeps:chain at SDK build time using the same prost syntax as tonic.The standalone test harness has no dep chain, so this PR adds a
testOverrideOptionsentry passing a placeholderextern_path=.=crate— the same patternneoeinstein-prost-crate(no_features) andneoeinstein-tonic(no_include) use to make their isolated test runs succeed without affecting production opts.plugin.sumfiles for both plugins (elizaandpetapis) are checked in;make test PLUGINS="anthropics/buffa anthropics/connect-rust"passes.