gRPC Server
Buat file server.go
Buat grpc server
grpcServer := grpc.NewServer()
grpcRoute() untuk handling routing grpc
Buat struct driverHandler yang mengimplementasikan seluruh interface DriverService protobuf
jalankan
go run server.go
call grpc dengan grpc client
ada banyak tool grpc client. ada yang berbasis gui seperti wombat maupun yang berbasis cli seperti grpcurl
setelah instal grpcurl, call grpc list driver dengan perintah :
grpcurl -import-path ~/jackyhtg/skeleton/proto -proto ~/jackyhtg/skeleton/proto/drivers/driver_service.proto -plaintext localhost:7070 skeleton.DriversService.List
call grpc create driver
grpcurl -plaintext -import-path ~/jackyhtg/skeleton/proto -proto ~/jackyhtg/skeleton/proto/drivers/driver_service.proto -d '{"name": "jacky", "phone": "08172221", "licence_number": "1234", "company_id": "UAT", "company_name": "Universal Alabama Tahoma"}' localhost:7070 skeleton.DriversService.Create
Last updated