cloudmapresolver

package module
v0.0.0-...-1eb03f8 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

README

cloudmapresolver

A gRPC name resolver inspired by sercand/kuberesolver but using the CloudMap ServiceDiscovery API (DiscoverInstances API) instead of Kubernetes Endpoints.

Usage

import (
    "github.com/aws/aws-sdk-go-v2/config"
    "github.com/jon-whit/cloudmapresolver"
)

cfg, err := config.LoadDefaultConfig(
    context.Background(),
    config.WithDefaultRegion("us-west-2"),
)
if err != nil {
    log.Fatalf("failed to initialize AWS SDK config, %v", err)
}

// register the cloudmapresolver
resolver.Register(cloudmapresolver.NewBuilder(cfg))

// with 'cloudmap' schema, grpc will use cloudmapresolver to resolve addresses
cc, err := grpc.Dial("cloudmap:///service.namespace:portname", opts...)

Client-side Load Balancing

You can use cloudmapresolver with a round_robin load balancing policy to provide client-side load balancing to each CloudMap service endpoint. For example,

conn, err := grpc.DialContext(
    context.Background(),
    "cloudmap:///myservice.mynamespace.demo",
    grpc.WithBalancerName("round_robin"),
    grpc.WithInsecure(),
)
if err != {
    ...
}

_ = conn // conn will be balanced between the CloudMap service endpoints.

Take a look at gRPC Load Balancing for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBuilder

func NewBuilder(config aws.Config) resolver.Builder

Types

This section is empty.

Jump to

Keyboard shortcuts

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