cloudmap

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2021 License: MIT Imports: 11 Imported by: 0

README

AWS Cloud Map Resolver for grpc-go

Go Reference

grpc-cloudmap-resolver is an implementation of grpc-go.Resolver using AWS Cloud Map.

Installation

go get github.com/KimMachineGun/grpc-cloudmap-resolver

Example

See godoc for more details.

package main

import (
	"log"

	"google.golang.org/grpc"

	cloudmap "github.com/KimMachineGun/grpc-cloudmap-resolver"
)

func main() {
	// register custom builder
	// cloudmap.Register(
	// 	cloudmap.WithSession(your_session),
	// 	cloudmap.WithRefreshInterval(1 * time.Minute),
	// )

	conn, err := grpc.Dial(
		cloudmap.BuildTarget("your-namespace", "your-service"),
		grpc.WithInsecure(),
		grpc.WithBlock(),
		grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`),
	)
	if err != nil {
		log.Fatal("cannot create a grpc client connection")
	}

	_ = conn
}

Documentation

Index

Constants

View Source
const (
	Scheme = "cloudmap"

	HealthStatusFilterAll       = servicediscovery.HealthStatusFilterAll
	HealthStatusFilterHealthy   = servicediscovery.HealthStatusFilterHealthy
	HealthStatusFilterUnhealthy = servicediscovery.HealthStatusFilterUnhealthy
)

Variables

This section is empty.

Functions

func BuildTarget added in v0.3.0

func BuildTarget(namespace, service string) string

BuildTarget builds grpc target string with given namespace and service.

func Register added in v0.4.0

func Register(opts ...Opt)

Register builds builder with given opts and register it to the resolver map. If you don't give any options, the builder will be registered with default options listed below.

The default builder was already registered by the init function, so you don't need to call this function to register the default builder.

Default Options:

Session: session.NewSession()
HealthStatusFilter: HealthStatusFilterHealthy
MaxResults: 100
RefreshInterval: 30s

Types

type Opt added in v0.5.0

type Opt func(*builder)

func WithHealthStatusFilter added in v0.4.0

func WithHealthStatusFilter(healthStatusFilter string) Opt

func WithMaxResults added in v0.4.0

func WithMaxResults(maxResults int64) Opt

func WithRefreshInterval added in v0.4.0

func WithRefreshInterval(refreshInterval time.Duration) Opt

func WithSession added in v0.4.0

func WithSession(sess *session.Session) Opt

Jump to

Keyboard shortcuts

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