hashring

package module
v0.0.0-...-644c959 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

README

grpc-hashring

A Go implementation of a gRPC client-side load balancer that uses consistent hashing to load balance gRPC subconnections.

Setup

conn, err := grpc.Dial(
	...,
    grpc.WithDefaultServiceConfig(`"loadBalancingConfig": {
        "hashring": {
          "keyReplicationCount": 2
        }
    }`),
    ...
)
if err != nil {
    ...
}
defer conn.Close()

Common Usages

Documentation

Index

Constants

View Source
const Name = "hashring"

Name is the name of hashring balancer.

Variables

This section is empty.

Functions

func ContextWithHashringKey

func ContextWithHashringKey(ctx context.Context, key string) context.Context

func HashringKeyFromContext

func HashringKeyFromContext(ctx context.Context) (string, bool)

func NewHashringBalancerBuilder

func NewHashringBalancerBuilder() balancer.Builder

Types

type HashringBalancerConfig

type HashringBalancerConfig struct {
	serviceconfig.LoadBalancingConfig
	KeyReplicationCount int `json:"keyReplicationCount"`
}

Directories

Path Synopsis
Package balancer implements a gRPC Balancer backed by a consistent hashring for connection selection.
Package balancer implements a gRPC Balancer backed by a consistent hashring for connection selection.

Jump to

Keyboard shortcuts

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