Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can use Connect for flatbuffers, too - the gRPC, gRPC-Web, and Connect wire protocols aren't tied to protobuf.

https://connect.build/docs/go/serialization-and-compression#... covers this, and coincidentally uses flatbuffers as the example :)



Very excited by what Buf is doing. Would love to see Bazel rules to completely automate all of this stuff and make a uniform dev environment possible.


Awesome, do you have any example code for flatbuffers?


I don't - I've never actually used flatbuffers. There are two pieces of code you'll want (if possible):

1. A `connect.Codec` implementation. I think it'd look almost the same as our Protobuf codec [0], but you'd use `FlatbuffersCodec.Marshal` and `FlatbuffersCodec.Unmarshal` (from github.com/google/flatbuffers/go). You _must_ have a `Codec`, but it looks like it should be pretty quick.

2. Ideally, you'd have a standalone program to parse your Flatbuffer schema and produce Connect code. The output would probably be very similar to `protoc-gen-connect-go`'s [1]. This isn't required, but it's a nice quality of life improvement (check out [1] to see the kind of conveniences it adds). With Protobuf, you'd do this via a `protoc` plugin and you wouldn't need to parse the schema yourself. From a quick look, I don't think `flatc` supports plugins at all - so maybe you'd either skip this step or put in the effort to parse the schema yourself?

[0]: https://github.com/bufbuild/connect-go/blob/main/codec.go#L5...

[1]: https://github.com/bufbuild/connect-go/blob/main/internal/ge...

Also, thank you for making me stop and think about this in detail. I just pulled Flatbuffers out of a hat when I was writing that part of the docs and assumed that `flatc` supported plugins like `protoc`. Turns out that when you assume... I'm updating that portion of the documentation now :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: