[feat](protocol): implement Protobuf codec and integrate into default WireCodec

- Introduced `protobufCodec` supporting length-prefixed Protobuf serialization/deserialization.
- Replaced JSON-based `DefaultCodec` with Protobuf-based implementation.
- Updated generated Protobuf Go types, aligning with `go_package` updates in `hopgate_stream.proto`.
- Added constants and safeguards for Protobuf envelope size limits.
- Modified `Makefile` to accommodate updated Protobuf generation logic.
This commit is contained in:
dalbodeule
2025-12-08 20:47:12 +09:00
parent 1fa5e900f8
commit 99be2d2e31
4 changed files with 199 additions and 7 deletions

View File

@@ -72,11 +72,15 @@ docker-server:
# - protoc-gen-go (go install google.golang.org/protobuf/cmd/protoc-gen-go@latest)
#
# Generates Go types under internal/protocol/pb from internal/protocol/hopgate_stream.proto.
# NOTE:
# - go_package in hopgate_stream.proto is set to:
# github.com/dalbodeule/hop-gate/internal/protocol/pb;protocolpb
# - With --go_out=. (without paths=source_relative), protoc will place the
# generated file under internal/protocol/pb according to go_package.
proto:
@echo "Generating Go code from Protobuf schemas..."
protoc \
--go_out=. \
--go_opt=paths=source_relative \
internal/protocol/hopgate_stream.proto
@echo "Protobuf generation completed."