@@ -55,8 +55,8 @@ syntax = "proto3";
5555// Indicates the go package where the generated file will be produced
5656option go_package = "path/to/your/proto/file";
5757
58- service {serviceName} Service {
59- rpc {serviceMethod} ({serviceRequest} ) returns ({serviceResponse} ) {}
58+ service <SERVICE_NAME> Service {
59+ rpc <SERVICE_METHOD> (<SERVICE_REQUEST> ) returns (<SERVICE_RESPONSE> ) {}
6060 }
6161```
6262
@@ -66,13 +66,13 @@ Users must define the type of message being exchanged between server and client,
6666procedure call. Below is a generic representation for services' gRPC messages type.
6767
6868``` protobuf
69- message {serviceRequest} {
69+ message <SERVICE_REQUEST> {
7070 int64 id = 1;
7171 string name = 2;
7272 // other fields that can be passed
7373 }
7474
75- message {serviceResponse} {
75+ message <SERVICE_RESPONSE> {
7676 int64 id = 1;
7777 string name = 2;
7878 string address = 3;
@@ -90,10 +90,10 @@ protoc \
9090 --go_opt=paths=source_relative \
9191 --go-grpc_out=. \
9292 --go-grpc_opt=paths=source_relative \
93- {serviceName} .proto
93+ < SERVICE_NAME > .proto
9494```
9595
96- This command generates two files, ` {serviceName} .pb.go` and ` {serviceName} _grpc.pb.go` , containing the necessary code for performing RPC calls.
96+ This command generates two files, ` <SERVICE_NAME> .pb.go` and ` <SERVICE_NAME> _grpc.pb.go` , containing the necessary code for performing RPC calls.
9797
9898## Prerequisite: gofr-cli must be installed
9999To install the CLI -
@@ -109,15 +109,15 @@ go install gofr.dev/cli/gofr@latest
109109gofr wrap grpc server -proto=./path/your/proto/file
110110 ```
111111
112- This command leverages the ` gofr-cli ` to generate a ` {serviceName} _server.go` file (e.g., ` customer_server.go ` )
112+ This command leverages the ` gofr-cli ` to generate a ` <SERVICE_NAME> _server.go` file (e.g., ` customer_server.go ` )
113113containing a template for your gRPC server implementation, including context support, in the same directory as
114114that of the specified proto file.
115115
116116** 2. Modify the Generated Code:**
117117
118- - Customize the ` {serviceName} GoFrServer` struct with required dependencies and fields.
119- - Implement the ` {serviceMethod} ` method to handle incoming requests, as required in this usecase:
120- - Bind the request payload using ` ctx.Bind(&{serviceRequest} ) ` .
118+ - Customize the ` <SERVICE_NAME> GoFrServer` struct with required dependencies and fields.
119+ - Implement the ` <SERVICE_METHOD> ` method to handle incoming requests, as required in this usecase:
120+ - Bind the request payload using ` ctx.Bind(&<SERVICE_REQUEST> ) ` .
121121 - Process the request and generate a response.
122122
123123## Registering the gRPC Service with Gofr
@@ -138,7 +138,7 @@ import (
138138func main () {
139139 app := gofr.New ()
140140
141- packageName.Register {serviceName} ServerWithGofr (app, &{packageName} .New {serviceName} GoFrServer ())
141+ packageName.Register <SERVICE_NAME> ServerWithGofr (app, &<PACKAGE_NAME> .New <SERVICE_NAME> GoFrServer ())
142142
143143 app.Run ()
144144}
@@ -163,7 +163,7 @@ func main() {
163163 grpc.ConnectionTimeout (10 * time.Second ),
164164 )
165165
166- packageName.Register {serviceName} ServerWithGofr (app, &{packageName} .New {serviceName} GoFrServer ())
166+ packageName.Register <SERVICE_NAME> ServerWithGofr (app, &<PACKAGE_NAME> .New <SERVICE_NAME> GoFrServer ())
167167
168168 app.Run ()
169169}
@@ -180,7 +180,7 @@ func main() {
180180
181181 app.AddGRPCUnaryInterceptors (authInterceptor)
182182
183- packageName.Register {serviceName} ServerWithGofr (app, &{packageName} .New {serviceName} GoFrServer ())
183+ packageName.Register <SERVICE_NAME> ServerWithGofr (app, &<PACKAGE_NAME> .New <SERVICE_NAME> GoFrServer ())
184184
185185 app.Run ()
186186}
@@ -227,26 +227,26 @@ For more details on adding additional interceptors and server options, refer to
227227 ``` bash
228228gofr wrap grpc client -proto=./path/your/proto/file
229229 ```
230- This command leverages the ` gofr-cli ` to generate a ` {serviceName} _client.go` file (e.g., ` customer_client.go ` ). This file must not be modified.
230+ This command leverages the ` gofr-cli ` to generate a ` <SERVICE_NAME> _client.go` file (e.g., ` customer_client.go ` ). This file must not be modified.
231231
232- ** 2. Register the connection to your gRPC service inside your {serviceMethod} and make inter-service calls as follows :**
232+ ** 2. Register the connection to your gRPC service inside your <SERVICE_METHOD> and make inter-service calls as follows :**
233233
234234 ``` go
235235// gRPC Handler with context support
236- func {serviceMethod} (ctx *gofr.Context ) (*{serviceResponse} , error ) {
236+ func <SERVICE_METHOD> (ctx *gofr.Context ) (*<SERVICE_RESPONSE> , error ) {
237237 // Create the gRPC client
238- srv , err := New {serviceName} GoFrClient (" your-grpc-server-host" , ctx.Metrics ())
238+ srv , err := New <SERVICE_NAME> GoFrClient (" your-grpc-server-host" , ctx.Metrics ())
239239 if err != nil {
240240 return nil , err
241241 }
242242
243243 // Prepare the request
244- req := &{serviceRequest} {
244+ req := &<SERVICE_REQUEST> {
245245 // populate fields as necessary
246246 }
247247
248248 // Call the gRPC method with tracing/metrics enabled
249- res , err := srv.{serviceMethod} (ctx, req)
249+ res , err := srv.<SERVICE_METHOD> (ctx, req)
250250 if err != nil {
251251 return nil , err
252252 }
@@ -307,7 +307,7 @@ func main() {
307307 app := gofr.New ()
308308
309309 // Create a gRPC client for the service
310- gRPCClient, err := client.New{serviceName} GoFrClient(
310+ gRPCClient, err := client.New< SERVICE_NAME > GoFrClient(
311311 app.Config.Get(" GRPC_SERVER_HOST" ),
312312 app.Metrics (),
313313 grpc.WithChainUnaryInterceptor(MetadataUnaryInterceptor),
@@ -374,7 +374,7 @@ func main() {
374374 return
375375 }
376376
377- gRPCClient, err := client.New{serviceName} GoFrClient(
377+ gRPCClient, err := client.New< SERVICE_NAME > GoFrClient(
378378 app.Config.Get(" GRPC_SERVER_HOST" ),
379379 app.Metrics (),
380380 grpc.WithTransportCredentials(creds),
@@ -409,7 +409,7 @@ GoFr provides built-in health checks for gRPC services, enabling observability,
409409### Client Interface
410410
411411```go
412- type {serviceName} GoFrClient interface {
412+ type <SERVICE_NAME> GoFrClient interface {
413413 SayHello(*gofr.Context, *HelloRequest, ...grpc.CallOption) (*HelloResponse, error)
414414 health
415415}
@@ -422,7 +422,7 @@ type health interface {
422422
423423### Server Integration
424424```go
425- type {serviceName} GoFrServer struct {
425+ type <SERVICE_NAME> GoFrServer struct {
426426 health *healthServer
427427}
428428```
0 commit comments