connectrpc-build: option to generate client code only

Open
#360 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start by tracing how Config::gate_client_feature is passed into code generation and how the plugin handles its existing option. Then locate the generator paths for service traits, ServiceExt, server types, dispatch, and clients; the payload does not name their files or tests. Done means generate_server(false) (and plugin option no_server) emits the requested client-side code without server code, while the default keeps server generation enabled.

Written by the indexing model from the issue text.

Description

A crate that only calls a service still gets the server trait, …ServiceExt, …Server<T> and their dispatch generated, and must compile them. That costs build time and code size, and server-side name clashes (#309; RPCs named like clone/into/as_ref) break crates that never implement the service.

Minimal proto:

syntax = "proto3";
package demo.v1;
message Req {}
message Resp {}
service DemoService {
  rpc Register(Req) returns (Resp);
}

connectrpc_build::Config::new().files(&["demo.proto"]).includes(&["."]).gate_client_feature(true).compile() then include! of the output fails with E0061 in the generated dispatch, though only DemoServiceClient is used.

Proposal: Config::generate_server(bool) (plugin option no_server), default true. When false, emit messages, views, Encodable impls where needed, and FooClient<T> only. This mirrors gate_client_feature, which already exists for the opposite direction.

Dominant language
Rust
Stars
544
Forks
77
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from connectrpc/connect-rust

All issues in connectrpc/connect-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.