tools/goctl/rpc/example/10-streaming/README-ko.md
이 예제는 서버 스트리밍, 클라이언트 스트리밍, 양방향 스트리밍이라는 세 가지 gRPC 스트리밍 패턴을 모두 보여줍니다.
stream.proto는 각 스트리밍 패턴을 보여주는 세 개의 RPC 메서드를 정의합니다.
go_package는 전체 모듈 경로를 사용합니다.
option go_package = "example.com/demo/pb";
먼저 출력 디렉터리에 go.mod를 초기화합니다.
mkdir -p output && cd output && go mod init example.com/demo && cd ..
그런 다음 코드를 생성합니다.
goctl rpc protoc stream.proto \
--go_out=output \
--go-grpc_out=output \
--zrpc_out=output \
--go_opt=module=example.com/demo \
--go-grpc_opt=module=example.com/demo \
--module=example.com/demo \
-I .
생성되는 디렉터리 구조:
output/
├── etc
│ └── streamsvc.yaml
├── go.mod
├── internal
│ ├── config
│ │ └── config.go
│ ├── logic
│ │ ├── bidistreamlogic.go
│ │ ├── clientstreamlogic.go
│ │ └── serverstreamlogic.go
│ ├── server
│ │ └── streamserviceserver.go
│ └── svc
│ └── servicecontext.go
├── pb
│ ├── stream.pb.go
│ └── stream_grpc.pb.go
├── streamservice
│ └── streamservice.go
└── streamsvc.go
stream), 클라이언트 스트리밍(요청에 stream), 양방향 스트리밍(양쪽 모두 stream).