elixir-grpc / grpc

An Elixir implementation of gRPC
https://hex.pm/packages/grpc
Apache License 2.0
1.36k stars 210 forks source link

Allow configurable Mint adapter #370

Closed caike closed 1 week ago

caike commented 2 weeks ago

Problem

The use case for this came from attempting to connect to a particular gRPC server which was rejecting the connection due to the default transport_options being used:

[
    timeout: :infinity,
    verify: :verify_peer,
    depth: 99,
    cacert_file: "...." # redacted
  ]

Solution

After overriding transport_options I was able to connect to said server. I believe the ability to override these options could also be useful for others. This PR allows the adapter options to be set from the client application via:

config :grpc, GRPC.Client.Adapters.Mint, transport_opts: []
sleipnir commented 2 weeks ago

Hi @caike! First of all, thank you for taking the time for us. If I'm not wrong we deprecated options via configuration in the past in favor of passing configurations as options directly at GRPC.Server.Supervisor initialization.

Am I right on this @polvalente ?

caike commented 1 week ago

Hi @caike! First of all, thank you for taking the time for us. If I'm not wrong we deprecated options via configuration in the past in favor of passing configurations as options directly at GRPC.Server.Supervisor initialization.

Am I right on this @polvalente ?

Thanks for the feedback and for maintaining this project!

How about when the application is simply a client to an external grpc server ? I have a client Stub that connects to an external server and I'm not using GRPC.Server.Supervisor at all. For more context, this my current use case

sleipnir commented 1 week ago

@caike Thank you very much!

Sorry for my inattention, you are correct and your PR already covers what is necessary. I will review it.

sleipnir commented 1 week ago

thank you for this work @caike