Skip to content

ekomobile/grpc-consul-resolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status GitHub release Go Report Card Downloads GoDoc

gRPC Consul resolver

This lib resolves Consul services by name.

Usage

Somewhere in your init code:

import (
    "github.com/ekomobile/grpc-consul-resolver"
)

// Will query consul every 5 seconds.
resolver.RegisterDefault(time.Second * 5)

Getting connection:

conn, err := grpc.DialContext(ctx, "srv://consul/my-awesome-service")

With round-robin balancer:

import (
    "google.golang.org/grpc/balancer/roundrobin"
)

conn, err := grpc.DialContext(ctx, "srv://consul/my-awesome-service", grpc.WithBalancerName(roundrobin.Name))