You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For more details on adding additional interceptors and server options, refer to the [official gRPC Go package](https://pkg.go.dev/google.golang.org/grpc#ServerOption).
198
+
149
199
## Generating gRPC Client using `gofr wrap grpc client`
150
200
151
201
**1. Use the `gofr wrap grpc client` Command:**
@@ -159,27 +209,132 @@ This command leverages the `gofr-cli` to generate a `{serviceName}_client.go` fi
// Call the gRPC method with tracing/metrics enabled
224
+
res, err:= srv.{serviceMethod}(ctx, req)
225
+
if err != nil {
226
+
returnnil, err
227
+
}
228
+
229
+
return res, nil
166
230
}
231
+
```
167
232
168
-
// Prepare the request
169
-
req:= &{serviceRequest}{
170
-
// populate fields as necessary
233
+
234
+
## Customizing gRPC Client with DialOptions
235
+
236
+
GoFr provides flexibility to customize your gRPC client connections using gRPC `DialOptions`. This allows users to configure aspects such as transport security, interceptors, and load balancing policies.
237
+
You can pass optional parameters while creating your gRPC client to tailor the connection to your needs. Here’s an example of a Unary Interceptor that sets metadata on outgoing requests:
This interceptor sets a metadata key `client-id` with a value of `GoFr-Client-123` for each request. Metadata can be used for authentication, tracing, or custom behaviors.
277
+
278
+
### Using TLS Credentials and Advanced Service Config
279
+
By default, gRPC connections in GoFr are made over insecure connections, which is not recommended for production. You can override this behavior using TLS credentials. Additionally, a more comprehensive service configuration can define retry policies and other settings:
280
+
281
+
```go
282
+
import (
283
+
"google.golang.org/grpc"
284
+
"google.golang.org/grpc/credentials"
285
+
)
286
+
287
+
// The default serviceConfig in GoFr only sets the loadBalancingPolicy to "round_robin".
response times etc." caption="Example monitoring dashboard using GoFr's built-in metrics" /%}
149
+
150
+
140
151
## Tracing
141
152
142
153
{% new-tab-link title="Tracing" href="https://opentelemetry.io/docs/concepts/signals/#traces" /%} is a powerful tool for gaining insights into your application's behavior, identifying bottlenecks, and improving
0 commit comments