This is a gRPC CSV reader system that streams data from a server to a client. The server reads rows from a CSV file and streams them to the client via gRPC.
Run the following command to install all required dependencies:
go mod tidy
If the files csv_reader.pb.go
and csv_reader_grpc.pb.go
are not already present in the proto/
folder, generate them using the this command:
protoc --go_out=. --go-grpc_out=. proto/csv_reader.proto
Ensure the following tools are installed:
-
Protocol Buffers Compiler (
protoc
): Install using Homebrew:brew install protobuf
-
Protobuf Go Plugin (
protoc-gen-go
): Install with:go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
-
gRPC Go Plugin (
protoc-gen-go-grpc
): Install with:go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
Make sure the Go binaries are in your PATH
environment variable. Run the this command:
export PATH=$PATH:$(go env GOPATH)/bin
Add this line to your shell configuration file (ie, .bashrc
or .zshrc
) to make it permanent:
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.zshrc
Reload your shell configuration:
source ~/.zshrc
Start the server by running:
go run main.go
You should see this message:
Server is running on port 50051...
Open a new terminal and run the client to fetch the CSV data:
go run client/client.go
You should now see the streamed rows from the server in the client’s output.