View Source GRPC.Client.Resolver.IPv4 (grpc v0.11.2)

Resolver for gRPC clients connecting to one or more IPv4 addresses.

This resolver handles target strings using the ipv4 URI scheme, which allows specifying one or multiple IPv4 addresses with explicit ports.

Target format

ipv4:addr:port[,addr:port,...]
  • IPv4 addresses must include a port.
  • Multiple addresses can be comma-separated.
  • service_config is always nil as literal IPv4 addresses do not support DNS TXT or xDS.

Examples

# Single IPv4
target = "ipv4:10.0.0.1:50051"
{:ok, %{addresses: addresses, service_config: nil}} =
  GRPC.Client.Resolver.IPv4.resolve(target)
addresses
# => [%{address: "10.0.0.1", port: 50051}]

# Multiple IPv4 addresses
target = "ipv4:10.0.0.1:50051,10.0.0.2:50052"
{:ok, %{addresses: addresses, service_config: nil}} =
  GRPC.Client.Resolver.IPv4.resolve(target)
addresses
# => [
#   %{address: "10.0.0.1", port: 50051},
#   %{address: "10.0.0.2", port: 50052}
# ]

See the gRPC naming documentation for more information: https://github.com/grpc/grpc/blob/master/doc/naming.md