Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use grpcAccess Client option in Gateway #45

Merged
merged 1 commit into from
May 7, 2024

Conversation

ianthpun
Copy link
Contributor

@ianthpun ianthpun commented May 7, 2024

This gives access to flowkit callers whatever option they want

@ianthpun ianthpun changed the base branch from main to feature/stable-cadence May 7, 2024 16:47

grpc.WithTransportCredentials(insecure.NewCredentials()),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already defaulted

@ianthpun ianthpun merged commit 7c9c45c into feature/stable-cadence May 7, 2024
2 checks passed
func NewGrpcGateway(network config.Network, opts ...grpc.DialOption) (*GrpcGateway, error) {
options := []grpc.DialOption{
func NewGrpcGateway(network config.Network, opts ...grpcAccess.ClientOption) (*GrpcGateway, error) {
opts = append(
Copy link
Member

@turbolent turbolent May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change isn't equivalent to the previous version: Before, the default was insecure, and the options passed to the function were appended, allowing to override this default. Now, the insecure option is appended to the given options, overriding options passed by the user.

Ideally also add a test that ensures this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure? Isn't it done where the defaults are set first, then any additonal options are appended to override the default?

https://github.com/onflow/flow-go-sdk/blob/master/access/grpc/client.go#L56-L58

Here the default is set as grpc.WithTransportCredentials(insecure.NewCredentials()), then any additional options are appended here:

https://github.com/onflow/flow-go-sdk/blob/master/access/grpc/client.go#L66-L70

meaning, shouldn't the final result be

dialOptions = []grpc.DialOptions{
grpc.WithTransportCredentials(insecure.NewCredentials()), // from the Default
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxGRPCMessageSize) // added from flowkit
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, i just understood what you meant 👍 let me fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants