Skip to content

Commit 647c134

Browse files
committed
added support for sending in custom dial options
1 parent c2a13ef commit 647c134

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

gateway/grpc.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ type GrpcGateway struct {
4545
}
4646

4747
// NewGrpcGateway returns a new gRPC gateway.
48-
func NewGrpcGateway(network config.Network) (*GrpcGateway, error) {
49-
50-
gClient, err := grpcAccess.NewClient(
51-
network.Host,
48+
func NewGrpcGateway(network config.Network, opts ...grpc.DialOption) (*GrpcGateway, error) {
49+
options := []grpc.DialOption{
5250
grpc.WithTransportCredentials(insecure.NewCredentials()),
5351
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxGRPCMessageSize)),
52+
}
53+
options = append(options, opts...)
54+
gClient, err := grpcAccess.NewClient(
55+
network.Host,
56+
options...,
5457
)
58+
5559
ctx := context.Background()
5660

5761
if err != nil || gClient == nil {
@@ -66,17 +70,23 @@ func NewGrpcGateway(network config.Network) (*GrpcGateway, error) {
6670
}
6771

6872
// NewSecureGrpcGateway returns a new gRPC gateway with a secure client connection.
69-
func NewSecureGrpcGateway(network config.Network) (*GrpcGateway, error) {
73+
func NewSecureGrpcGateway(network config.Network, opts ...grpc.DialOption) (*GrpcGateway, error) {
7074
secureDialOpts, err := grpcutils.SecureGRPCDialOpt(strings.TrimPrefix(network.Key, "0x"))
7175
if err != nil {
7276
return nil, fmt.Errorf("failed to create secure GRPC dial options with network key \"%s\": %w", network.Key, err)
7377
}
7478

75-
gClient, err := grpcAccess.NewClient(
76-
network.Host,
79+
options := []grpc.DialOption{
7780
secureDialOpts,
7881
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxGRPCMessageSize)),
82+
}
83+
options = append(options, opts...)
84+
85+
gClient, err := grpcAccess.NewClient(
86+
network.Host,
87+
options...,
7988
)
89+
8090
ctx := context.Background()
8191

8292
if err != nil || gClient == nil {
@@ -174,7 +184,6 @@ func (g *GrpcGateway) GetEvents(
174184
startHeight uint64,
175185
endHeight uint64,
176186
) ([]flow.BlockEvents, error) {
177-
178187
events, err := g.client.GetEventsForHeightRange(
179188
g.ctx,
180189
eventType,

0 commit comments

Comments
 (0)