From 9d8c4d2f25564f5a58306c87d20680d06951a583 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 28 Nov 2023 21:56:41 -0500 Subject: [PATCH] prepare for 3.0 --- CHANGES.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++ dune-project | 2 +- ocaml-protoc.opam | 2 +- pbrt.opam | 2 +- pbrt_services.opam | 2 +- pbrt_yojson.opam | 2 +- 6 files changed, 72 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d7ba38d6..e2ebd84d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,70 @@ + +## 3.0 + +Major version that breaks code for every user. Sorry! + +### Breaking + +- Generated code now always fits into 2 files: code + for `foo.proto` is produced in `foo.ml` and `foo.mli`. + This follows a fairly large internal refactor that enables + a plugin architecture internally (which facilitated codegen for + services). + All encoder/decoder functions also have a new name now, + so that they don't collide inside the same file. +- CLI flags now use `--this-style` rather than `-this-style` +- Bump minimal OCaml version to 4.08 + +### Performance + +- encode probotufs backward, which means we can write directly + into a single buffer (which is not possible in a forward mode + because sub-messages require an unknown amount of prefix space + to write their size as a varint) +- add C stubs for pbrt +- use Bytes functions to read/write fixed size integers +- inlining annotations +- more benchmarks, helping optimization overall +- reduce allocations drastically, by having the generated code + create fewer closures + + +### Services + +- add `pbrt_services` runtime library +- generate code for `service` statements. This is a big feature + for users who want to implement RPC systems using protobuf. + The generated code is agnostic to whatever RPC implementation + will use it, it only packs together RPC method names and path + with the relevant encoders/decoders. Services require + both JSON and binary encoders/decoders to be present. + +### JSON + +- migrate `pbrt_yojson` into the main ocaml-protoc repo +- JSON runtime support for empty messages +- Add support for bytes in JSON encoding +- Add support for encoding and decoding maps in JSON + +### Other features and fixes + +- add `--make` flag to generate `make` functions that take fewer + optional arguments. This helps preventing the user from + forgetting important arguments when they're encoding to protobuf. + Arguments actually marked as `optional` in the .proto file + are still optional. +- Support maps/lists in options +- add Pbrt.Decoder.of_substring +- Allow options to be named like `(validate.rules).message.required` +- support code generation for empty messages +- Empty proto file is a valid proto as well + +### Testing + +- expect-style tests for parser +- Tests for option parsing +- Test demonstrating parse error printing + ## 2.4 - expose compiler library as `ocaml-protoc.compiler-lib` diff --git a/dune-project b/dune-project index 40eca41e..66215d34 100644 --- a/dune-project +++ b/dune-project @@ -1,7 +1,7 @@ (lang dune 2.0) (name ocaml-protoc) (generate_opam_files true) -(version 2.4) +(version 3.0) (maintainers "Maxime Ransan " "Simon Cruanes") (authors "Maxime Ransan " "Simon Cruanes") diff --git a/ocaml-protoc.opam b/ocaml-protoc.opam index 1c76c084..d61b673a 100644 --- a/ocaml-protoc.opam +++ b/ocaml-protoc.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "2.4" +version: "3.0" synopsis: "Pure OCaml compiler for .proto files" maintainer: ["Maxime Ransan " "Simon Cruanes"] authors: ["Maxime Ransan " "Simon Cruanes"] diff --git a/pbrt.opam b/pbrt.opam index ffe27bd1..87566440 100644 --- a/pbrt.opam +++ b/pbrt.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "2.4" +version: "3.0" synopsis: "Runtime library for Protobuf tooling" maintainer: ["Maxime Ransan " "Simon Cruanes"] authors: ["Maxime Ransan " "Simon Cruanes"] diff --git a/pbrt_services.opam b/pbrt_services.opam index b6132192..d2aa5801 100644 --- a/pbrt_services.opam +++ b/pbrt_services.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "2.4" +version: "3.0" synopsis: "Runtime library for ocaml-protoc to support RPC services" maintainer: ["Maxime Ransan " "Simon Cruanes"] authors: ["Maxime Ransan " "Simon Cruanes"] diff --git a/pbrt_yojson.opam b/pbrt_yojson.opam index 2a47f725..5903c926 100644 --- a/pbrt_yojson.opam +++ b/pbrt_yojson.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "2.4" +version: "3.0" synopsis: "Runtime library for ocaml-protoc to support JSON encoding/decoding" maintainer: ["Maxime Ransan " "Simon Cruanes"]