resolver

package module
v2.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2020 License: MIT Imports: 5 Imported by: 0

README

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))

Documentation

Index

Constants

View Source
const (
	Scheme = "srv"
)

Variables

This section is empty.

Functions

func RegisterDefault

func RegisterDefault(watchInterval time.Duration)

Types

type ConsulResolver

type ConsulResolver struct {
	// contains filtered or unexported fields
}

func (*ConsulResolver) Close

func (r *ConsulResolver) Close()

func (*ConsulResolver) ResolveNow

func (r *ConsulResolver) ResolveNow(resolver.ResolveNowOptions)

type ConsulResolverBuilder

type ConsulResolverBuilder struct {
	WatchInterval      time.Duration
	ConsulClientConfig *api.Config
}

func (*ConsulResolverBuilder) Build

func (*ConsulResolverBuilder) Scheme

func (b *ConsulResolverBuilder) Scheme() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL