ration/scripts/gen-proto.sh
caelum0x 77324a7b50 feat(ration): split gateway into auth/tenant-registry/card-issuance/webhook-ingestion
Phase 2 service decomposition per docs/SCALE-EXPANSION.md section 1: extracts
internal/{airwallex,bridge,card,tenant,httpserver} out of the monolithic
gateway into four independently deployable gRPC services (each own go.mod,
Dockerfile, and tests), with gateway now a thin BFF that fans out through new
cardissuanceclient/webhookeventsclient gRPC clients. gateway.proto's external
surface is unchanged — agent/tui/cli still talk to gateway exactly as before.

Verified: all 10 go.work modules build and `go test ./...` passes across
every one, including the new gateway client packages against the live split
services (via `make build && make test`).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-19 12:25:41 +03:00

32 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Generates Go protobuf/gRPC stubs into pkg/pb/*.
# Rust stubs are generated at build time by services/ledger-core/build.rs (tonic-build),
# not here.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# protoc writes relative to the module root (via --go_opt=module=...), landing
# at $ROOT/pkg/pb/<common|gateway|ledger>/*.pb.go to match each proto's
# go_package option (github.com/caelum0x/ration/pkg/pb/<name>). Do NOT switch
# to paths=source_relative: with multiple protos in one flat proto/ dir, that
# writes flat files straight into pkg/pb/, which collide with (and shadow)
# these package subdirectories.
MODULE="github.com/caelum0x/ration"
mkdir -p "$ROOT/pkg/pb"
GOBIN_DIR="$(go env GOPATH)/bin"
export PATH="$PATH:$GOBIN_DIR"
if ! command -v protoc-gen-go >/dev/null 2>&1; then
echo "installing protoc-gen-go / protoc-gen-go-grpc..."
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
fi
protoc \
--proto_path="$ROOT/proto" \
--go_out="$ROOT" --go_opt=module="$MODULE" \
--go-grpc_out="$ROOT" --go-grpc_opt=module="$MODULE" \
"$ROOT"/proto/*.proto
echo "generated Go stubs in $ROOT/pkg/pb"