grpcconf

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package grpcconf helps configure gRPC service connections.

Index

Constants

View Source
const (
	// PolicyPickFirst opens a single connection to one backend and stays on it
	// for the life of the connection. This is gRPC's default and the zero value.
	PolicyPickFirst = "pick_first"

	// PolicyRoundRobin spreads calls across every backend address the resolver
	// returns and drops failed sub-channels on re-resolution. Use it when the
	// target is a *headless* Kubernetes Service (so DNS returns every pod IP);
	// it is what stops a single rolled pod from taking out the client.
	PolicyRoundRobin = "round_robin"
)

Load-balancing policies accepted by Service.Policy.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	Host string `json:"host"`
	Port string `json:"port"`

	// Insecure is required by gRPC to say when there are no TLS connection
	// details.
	Insecure bool `json:"insecure"`

	// PublicURL defines the base url to use when forwarding the user to
	// public side of the service. Not all services required this.
	PublicURL string `json:"public_url"`

	// Policy selects the client-side load-balancing policy: PolicyPickFirst
	// (the default, and the zero value) or PolicyRoundRobin. Any other value
	// falls back to gRPC's default (pick_first).
	Policy string `json:"policy"`
}

Service defines a generic base for dealing with connection details to an internal gRPC service.

func (*Service) Connection

func (s *Service) Connection(opts ...grpc.DialOption) (*grpc.ClientConn, error)

Connection provides an instance of the grpc connection. Caller-supplied opts are applied last, so a caller can override any of the defaults above.

func (*Service) DialOptions

func (s *Service) DialOptions() []grpc.DialOption

DialOptions provides an array of gRPC DialOptions based on the defined service configuration.

func (*Service) URL

func (s *Service) URL() string

URL provides the result of joining the Host and Port together.

Jump to

Keyboard shortcuts

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