LibraryActive

pw_rpc

Efficient, low-code-size RPC system for embedded devices with benchmarking and stress testing utilities.

Open source page

Field note

What it does

pw_rpc provides an RPC service and Python utilities for measuring throughput, latency, and resilience of an RPC deployment over its underlying transport.

Capabilities

Available capabilities

Tags

Tags

Ways to use it

Ways to use it

pypi

Python / pw_rpc

sdk

C++ / Not filed

other

C++ / https://pigweed.dev/pw_rpc/pwpb/

sdk

C++ / Not filed

other

C++ / Not filed

sdk

C++ / Not filed

sdk

C++ / Not filed

npm

typescript / Not filed

Product features

Product features

pw.rpc.Benchmark service

Low-level RPC interface for sending bulk data between client and server, defined in pw_rpc/benchmark.proto.

Benchmarking utility

Separate utility for measuring and debugging RPC performance.

BidirectionalEcho RPC

Server responds to each request payload; client stops the RPC by cancelling it.

Call objects

Callback client

callback_client.Impl supports invoking RPCs synchronously or asynchronously.

RPC Callbacks

Register onNext, onComplete, and onError callbacks.

ChannelOutput interface

Implement ChannelOutput::Send() to frame and transmit packets.

pw::rpc::ClientServer

Dual-role nodes acting as both client and server.

Client synchronous call wrappers

Client utilities

Utilities for using pw_rpc.Client, including single-channel and configurable clients.

ClientServer

C++ benchmark service

Raw RPC implementation of the benchmark service suitable for any system running pw_rpc, via pw_rpc/benchmark.h.

C++ with Nanopb

Lightweight C struct message generator recommended for embedded C++.

C++ with pw_protobuf

Type-safe pure C++ message generator.

C++ with raw RPC

Zero-copy byte buffer RPCs and method fallback mechanics.

C++ server and client

C++ server and client library API guides.

Device API

Easier to use when calling RPC via HDLC over WebSerial.

Embedded-friendly

Designed for embedded devices with low code size.

Future-based invocation

ListenableFuture wrappers for asynchronous Java code.

Client-server fuzz stress test

Fuzz and stress-test pw_rpc across concurrent threads and fluctuating channel conditions.

Generated C++ service base classes

pw_rpc automatically generates C++ service base classes from your .proto files.

Generated .rpc.pb.h header

A C++ header is generated per .proto file with .proto replaced by .rpc.pb.h.

Generated service class

A C++ class is generated for each service in the .proto file, in a pw_rpc::nanopb sub-namespace.

pw_hdlc framing

Example packetizer used in the transport ingress pipeline.

Java client

Android and JVM client library in dev.pigweed.pw_rpc.

Java/Kotlin client

Client implementation under package dev.pigweed.pw_rpc for Android, desktop JVM tools, and test frameworks.

The Method class

Mixing raw methods into services

Implement individual methods as raw inside a Nanopb or pw_protobuf service.

Multi-language support

Supports C++, Java, JavaScript, Python, and TypeScript.

Nanopb codegen

Recommended method for implementing the service class in C++.

Packet protocol

Detailed description of the pw_rpc packet protocol.

Promise API

call()/finishAndWait() to send requests and await responses.

proto3 service definition

Define RPC services and message types in a Protocol Buffer file using proto3 syntax.

Protocol Buffer services

Services and messages defined in shared .proto files.

pw_protobuf codegen

Alternative codegen option for implementing the service class.

pw_protobuf code generation

Generates .rpc.pwpb.h headers with service and client classes from .proto files.

PwpbServerReader

Helper for client streaming requests with set_on_next callback.

PwpbServerReaderWriter

Helper for bidirectional streaming RPCs.

PwpbServerWriter

Helper with Write, Finish, and TryFinish methods for streaming responses.

Python client

pw_rpc.client provides a pw_rpc client for Python.

Python utilities

Python utilities for measuring throughput, latency, and resilience of an RPC deployment.

Raw clients

Raw clients send and receive raw byte spans directly.

Raw methods

Fall back to raw methods when generated codegen is not used.

C++ with raw RPC

C++ service methods and clients send and receive raw byte spans without generated protobuf structs.

RPC calls introspection

Server::ProcessPacket()

Ingress entry point that validates and dispatches incoming packets.

Testing fixtures

TypeScript Client

Call Pigweed RPCs from TypeScript.

UnaryEcho RPC

Server responds with the payload the client sent.

Unit testing

Test unary and streaming RPC services with provided test contexts.