Skip to content

Releases

v0.4.3: built with mise instead of Bazel; references and real validation in the examples

Choose a tag to compare

@github-actions github-actions released this 21 Nov 22:20
v0.4.3
45795d3

The generated code and the runtime are the same as in 0.4.2. For a consumer, one thing changes: building the plugin from source (cargo install protoc-gen-protocontract-buffa) needs Rust 1.100.0. The release binaries need no Rust, and their names and checksums-sha256.txt are as before.

Added

  • examples/glossary uses references to a service: a catalog service,
    Glossaries, keeps glossaries by topic, takes one as a reference in a
    message field (Add(Shelf)), and returns one (Open(Topic) gives a
    GlossaryRef). The consumer opens its topic and annotates through the
    glossary it gets back; the application wires it all. No change to the
    plugin or the runtime.

Changed

  • examples/refs validates for real: Alarm and Tick declare
    protovalidate rules (a required, non-empty label, a required clock, at
    most three backups, no time before the epoch), Alarms.Set fails with
    the new ALARMS_ERROR_CODE_INVALID_ALARM, and the tests check each rule.
    The README describes validate=true with an example. protovalidate's
    protos come from mise (http:protovalidate 1.2.2, staged by
    mise run protos), not from the Buf Schema Registry.

  • The example's protovalidate moves to protovalidate-buffa 0.8.0 with
    protoc-gen-protovalidate-buffa 0.11.0 (released together: time
    replaces chrono). The Validate impl that validate=true emits is
    unchanged and builds against both.

  • Every dependency is declared once, in the root [workspace.dependencies],
    and an unused dependency fails the build (cargo::unused_dependencies,
    Cargo 1.100). Nothing changes for a consumer of the crates.

  • The repository builds with Cargo and mise
    instead of Bazel: mise run gate is the gate (generated files, clippy,
    rustfmt, cargo-deny, buf lint and format, markdownlint, tests),
    mise run generate refreshes the golden files and the examples, and
    mise run format formats in place. The release workflow runs the gate
    on the same six platforms, the golden check now on Windows ARM64 too.
    The plugin's binaries, their names, and checksums-sha256.txt are
    unchanged, so the bazel_utils catalog and a mise github: backend
    keep working; the crates are unchanged.

  • The dependency check is cargo-deny (deny.toml): advisories as before,
    plus licences, duplicate crates, and sources.

  • The pinned toolchain is Rust 1.100.0 (was 1.99.1), and building the
    plugin from source (cargo install protoc-gen-protocontract-buffa) now
    needs it. The runtime and the generated code still need Rust 1.92; the
    generated code is the same.

  • Cargo.lock takes the newest version of each dependency that is at
    least two days old (tokio 1.54.1, syn 3.0.10, and others), which the
    plugin's release binaries are built with. The version ranges in
    Cargo.toml, what a consumer resolves against, are unchanged.

Removed

  • The Bazel module protocontract_buffa (MODULE.bazel and every
    BUILD.bazel). No consumer took it through bazel_dep; a Bazel build
    takes the plugin from the bazel_utils catalog as before.

v0.4.2: a dropped bridge stream starts no more work

Choose a tag to compare

@github-actions github-actions released this 23 Oct 21:39
v0.4.2
df66223

Fixed

  • A stream that Offload or Blocking pulls from a sync iterator on the
    blocking pool (an Offload reply stream, a Blocking::feed request
    stream) no longer calls the iterator's next once its reader is gone.
    Before, after each item was handed over the pull called next again
    without checking, and only the send after it found the stream dropped:
    one more unit of the implementation's work ran for nobody, possibly
    after the caller had dropped the stream and moved on. A next already
    running when the stream is dropped still finishes.

Changed

  • Build pin: bazel_utils 0.4.2. It adds plugin versions to its catalog
    and changes nothing this build uses; the generated code is the same.

Upgrading

No code change is needed: update protocontract to 0.4.2
(cargo update -p protocontract). The plugin's generated code is the same
as in 0.4.1.

v0.4.1: the docs of reference modules link their type

Choose a tag to compare

@github-actions github-actions released this 19 Oct 16:02
v0.4.1
c0d0b3f

Fixed

  • The doc comment on the module of a reference type links the type through
    that module ([ClockRef](clock_ref::ClockRef)): the comment sits
    outside the module, where the type is not in scope, so rustdoc with
    warnings denied failed with unresolved link. Regenerate to get it.

v0.4.0: references to a service in messages, requests, and replies

Choose a tag to compare

@github-actions github-actions released this 18 Oct 08:00
v0.4.0
ffbc6db

Added

  • References to a service. An empty message marked
    option (protocontract.v1.service) = "pkg.Service"; stands for an
    implementation of that service: the plugin emits a type for it
    (<module>::<Name>, e.g. clock_ref::ClockRef) that holds the
    implementation in the form it was given, and buffa maps the message to it
    with an extern_path, so a field, a request, or a reply can carry an
    implementation. The receiver takes the form it needs with to_sync,
    to_async_inline, or to_async_offload. A reference does not survive
    encoding: decoded it is RuntimeCode::Unbound when used, and it has no
    JSON form. The option is declared in protocontract/v1/options.proto,
    shipped in the protocontract crate under proto/.
  • Plugin parameters json=<true|false> and validate=<true|false>: with
    buffa's json=true, reference types get serde impls too; next to
    protoc-gen-protovalidate-buffa, they implement Validate (always
    valid), which it calls on every message field.
  • RuntimeCode::Unbound and RuntimeCode::NoRuntime.
  • Every Dyn<Service>Async handle has ptr_eq: whether two handles hold
    the same implementation.
  • examples/refs: a reference in a field, a list, a request, and a reply.

Changed

  • RuntimeCode has two more variants, so an exhaustive match on it no
    longer compiles: add an arm for Unbound and NoRuntime, or a
    wildcard.
  • Build pins: bazel_utils 0.4.0 and Buf CLI v1.74.0. The pins alone do not
    change the generated code.
  • buildifier, markdownlint, buf lint, rustfmt, and cargo-audit now run on
    Windows too, and the golden checks of the generated code on Windows
    ARM64: the reasons they were off are gone (bazel_utils runs its test
    scripts on Windows since 0.3.0, and catalogs every plugin there). Only
    the rustdoc tests stay off on Windows, where rules_rust cannot link them;
    cargo test runs them. The release workflow names each of these tests,
    so a platform that cannot run one fails.

Upgrading from 0.3

  • Take protocontract = "0.4" and the 0.4.0 plugin together.
  • An exhaustive match on RuntimeCode needs arms for Unbound and
    NoRuntime, or a wildcard.
  • Nothing else changes in the generated code of an existing contract but
    the new Dyn<Service>Async::ptr_eq.
  • To use references: import protocontract/v1/options.proto (in the
    protocontract crate, under proto/), mark an empty message with
    option (protocontract.v1.service) = "pkg.Service";, and map it to
    <mount>::<module>::<Name> with the same extern_path in both
    protoc-gen-buffa and this plugin.

v0.3.1: ready for crates.io, dependency ranges, rustfmt in the gate

Choose a tag to compare

@github-actions github-actions released this 16 Oct 18:59
v0.3.1
7ddd71a

Added

  • protocontract and protoc-gen-protocontract-buffa are ready for
    crates.io: keywords, categories, the license text in each package, and
    docs.rs builds protocontract with every feature, so it shows Offload
    and Blocking. A logo for the README and the rustdoc pages.
  • bazel test //... checks the formatting of the hand-written Rust
    (//rust:fmt, rustfmt of the pinned toolchain).

Changed

  • The workspace takes its dependencies as caret ranges instead of exact
    pins (buffa = "0.9.2", was "=0.9.2"), so a consumer of
    protocontract is not held to one version of buffa, futures-core, or
    tokio. Cargo.lock still fixes the versions this repository builds and
    tests.
  • The README takes protocontract from crates.io
    (protocontract = "0.3") and the plugin with cargo install, links to
    GitHub by absolute URLs, and corrects the names of the runtime's codes
    (RuntimeCode::Panicked, not PANICKED), the strategy: all of the
    example buf.gen.yaml, and how the static release binaries are built.

Consumers of the generated code and the runtime change nothing: the
generated code, the runtime API, and the plugin parameters are the same
as in 0.3.0.

v0.3.0: renamed to protocontract-buffa and protoc-gen-protocontract-buffa

Choose a tag to compare

@github-actions github-actions released this 16 Oct 18:17
v0.3.0
a055230

Changed

  • Breaking: the project is renamed to protocontract-buffa. The
    repository is github.com/sonalect/protocontract-buffa.rs (GitHub
    redirects sonalect/proto-contract.rs), the plugin and its binary are
    protoc-gen-protocontract-buffa (was protoc-gen-contract-rust), and
    the Bazel module is protocontract_buffa (was contract). The
    generated code is the same except for its header,
    // @generated by protoc-gen-protocontract-buffa. DO NOT EDIT.; the
    runtime crate keeps its name, protocontract, and the output files keep
    theirs (<stem>.__contract.rs, <pkg>.mod.rs).
  • The minimum Rust version of protocontract and of the generated code is
    1.92 (it was 1.99.1 in 0.2.2): 1.92 is the oldest rustc that compiles the
    generated handles of bidi-streaming methods. The release workflow builds
    and tests both with Rust 1.92. The plugin, built from source with
    cargo install, needs Rust 1.99.1.

What a consumer changes

  • buf.gen.yaml: local: protoc-gen-protocontract-buffa instead of
    local: protoc-gen-contract-rust.
  • The protocontract git dependency:
    git = "https://github.com/sonalect/protocontract-buffa.rs", tag = "v0.3.0".
  • Release binaries are named
    protoc-gen-protocontract-buffa-v0.3.0-<os>-<arch>; a script or catalog
    that downloads them takes the new names.
  • No Rust code changes: no renamed items, no new signatures, no plugin
    parameter changes.

v0.2.2: Rust 1.99.1 and refreshed build pins

Choose a tag to compare

@github-actions github-actions released this 16 Oct 17:44
v0.2.2
9d03263

Changed

  • Build pins refreshed: bazel_utils 0.3.4 (a prebuilt protoc on
    Windows ARM64 instead of one compiled from source), Rust toolchain 1.99.1,
    syn 3.0.9, and tokio 1.53.3. The generated code is unchanged.
  • The minimum Rust version (rust-version) is 1.99.1.

Consumers of the generated code and the runtime change nothing in their
code: no renamed items, no new signatures, no plugin parameter changes.
They need Rust 1.99.1 or newer to build protocontract 0.2.2.

v0.2.1: refreshed build pins and Ubuntu 26.04 release builds

Choose a tag to compare

@github-actions github-actions released this 12 Oct 07:48
v0.2.1
411312b

Changed

  • The plugin's release binaries are built and checked on Ubuntu 26.04 for
    Linux (amd64 and arm64). They stay static musl binaries.
  • Build pins refreshed: Bazel 9.3.0, bazel_utils 0.3.2,
    protoc-gen-connect-rust v0.9.1 for the golden generate, and syn 3.0.7.
    The generated code is unchanged.

Consumers of the generated code and the runtime change nothing: no renamed
items, no new signatures, no plugin parameter changes.

v0.2.0: open error codes, the protocontract crate, and a worked example

Choose a tag to compare

@github-actions github-actions released this 07 Oct 10:13
v0.2.0
7ee0ca7

One error type for every contract, with codes the contract declares itself, a renamed runtime crate, and an example of a provider and a consumer that know only the generated API.

Added

  • examples/glossary: a contract in use. A proto with a service and its
    error codes, the crate generated from it, a provider that implements the
    traits, a consumer that calls them without knowing the provider, and the
    application that wires the two (cargo run -p glossary-app).
  • Open error codes: protocontract::ErrorCode, implemented by every protobuf
    enum that protoc-gen-buffa generates and by hand for a Rust enum, and
    protocontract::Code, a code with its type erased. A contract declares the
    codes its callers may branch on as an enum next to its service.
  • protocontract::Fault, the trait of a failure (code, retryable,
    backtrace), and protocontract::Failure, the ready-made fault (code,
    message, with_retryable, with_source, a captured backtrace). Any
    Fault converts into protocontract::Error with ?.
  • Error::is, code_as, retryable, stack, backtrace,
    downcast_ref, and context; the protocontract::Context extension adds a
    stack frame to the error of a Result (.context("load"),
    .with_context(|| …)).
  • The plugin finds a service's error-code enum by name
    (GreeterErrorCode, then GreeterServiceErrorCode, in the package of
    GreeterService), emits the alias GreeterServiceErrorCode next to the
    traits, and names it in their rustdoc. A service without such an enum is
    generated as before; a message or enum already named like the alias
    fails the run.
  • protocontract::RuntimeCode: PANICKED (Offload), CANNOT_BLOCK
    (Blocking inside a current-thread runtime), CANCELLED (a blocking
    task dropped by its runtime).

Changed

  • Breaking. The runtime crate contract is now protocontract
    (directory rust/protocontract, Bazel target //rust/protocontract).
    Depend on protocontract and replace contract:: paths; the plugin's
    runtime= default is ::protocontract. A crate that mounts the traits
    may now name their module contract.
  • Breaking. contract::Status is now protocontract::Error: every
    generated method returns Result<_, protocontract::Error>. Build one with
    Error::new(code, message), where code is a value of the contract's
    error enum, or from a Failure or a Fault of your own.
  • Breaking. The bridges report RuntimeCode values instead of
    INTERNAL and FAILED_PRECONDITION.
  • The runtime depends on buffa (for ErrorCode on its enums) instead of
    buffa-types.
  • Each method's parameter is named after its message in snake case
    (word: Word, greet_request: GreetRequest), plural for an inbound
    stream (items), instead of request and requests. Implementations
    are unaffected: Rust does not bind parameter names.

Removed

  • Breaking. The fixed google.rpc.Code set (contract::Code as an
    enum) and the per-code constructors (Status::invalid_argument, …):
    codes are open (see Added).
  • Breaking. Status::with_details, details, and into_parts: the
    calls stay in one process, so the wire payloads of google.rpc.Status
    have no use.
  • Breaking. PartialEq on the error: a fault cannot be compared.
    Compare codes (error.is(code)) instead.

Upgrading from 0.1.0

  1. Depend on protocontract instead of contract, from tag v0.2.0,
    and replace contract:: paths with protocontract::. A plugin run
    with runtime= set keeps its path; without it the generated code now
    names ::protocontract.
  2. Rename Status to Error in implementations and callers.
  3. Declare the codes of each service as a proto enum named
    <Service>ErrorCode next to it (for service Greeter,
    enum GreeterErrorCode), and replace Status::invalid_argument(msg)
    and the other per-code constructors with
    Error::new(GreeterErrorCode::…, msg); use Failure for a retryable
    failure or one with a source.
  4. Branch with error.is(code) or error.code_as::<GreeterErrorCode>()
    instead of comparing error.code() with Code::…; compare codes, not
    errors, in tests.
  5. Code that matched INTERNAL or FAILED_PRECONDITION from Offload or
    Blocking matches RuntimeCode::Panicked or
    RuntimeCode::CannotBlock.

v0.1.0: plain Rust sync and async traits for protobuf services

Choose a tag to compare

@github-actions github-actions released this 06 Oct 19:39
v0.1.0
1163517

First release.

Added

  • protoc-gen-contract-rust, a protoc plugin that emits, per protobuf
    service:

    • <Service>Sync, whose methods return Result<Reply, contract::Status>.
      It is dyn-compatible: Arc<dyn <Service>Sync>.
    • <Service>Async, whose methods return
      impl Future<Output = Result<Reply, Status>> + Send, so implementations
      write plain async fn and generic callers pay no allocation.
    • Dyn<Service>Async, a cloneable handle (new, from_arc) that holds
      any <Service>Async implementation behind dynamic dispatch, implements
      the trait itself, and implements Debug.

    Requests are taken by value and replies returned owned. Comments in the
    .proto become rustdoc.

  • Streaming methods of every kind: server, client, and bidirectional. The
    sync form takes and returns contract::BoxIter<'static, _>, the async
    form impl contract::Stream; items are Result<_, Status>, a reply
    stream sits inside the call's Result, and no stream borrows the
    service.

  • Bridges between the forms, for every kind of method: contract::Inline
    (a sync implementation's async form, run inside poll),
    contract::Offload (the same on tokio's blocking pool), and
    contract::Blocking (an async implementation's sync form). Offload
    and Blocking come with the runtime's tokio feature. Blocking inside
    a current-thread runtime fails with FAILED_PRECONDITION instead of
    panicking, and every bridge ends a stream after its first Err.

  • Plugin parameters buffa_module= (crate included), extern_path=,
    file_per_package, and element_memory_limit=, as
    protoc-gen-connect-rust reads them, plus runtime= for the path of the
    runtime crate and gate_tokio_feature[=<name>] to put the Offload and
    Blocking impls behind a Cargo feature. Message paths are absolute and
    match protoc-gen-buffa 0.9.2. Output is a <stem>.__contract.rs per
    proto and a <pkg>.mod.rs stitcher per package for
    protoc-gen-buffa-packaging (filter=services), or one
    <dotted.pkg>.rs per package with file_per_package. The output can sit
    next to protoc-gen-connect-rust's, in the same modules.

  • The plugin refuses, with a message that names the proto element: a
    message type no mapping covers, two methods with one Rust name, a
    generated name that another item of the package's module (buffa,
    connect-rust, or Contract) already has, and any unknown parameter.

  • Runtime crate contract: Status (code, message, Any details; a
    mirror of google.rpc.Status), Code (the 17 google.rpc.Code values),
    BoxFuture, BoxIter, BoxStream, Stream (re-exported from
    futures-core), IterStream, Inline, and with tokio ChannelStream,
    Offload, and Blocking.

  • Release binaries of the plugin for Linux, macOS, and Windows on amd64
    and arm64, static where the platform allows (macOS links only system
    libraries), with their sha256 in checksums-sha256.txt.