grpcserverutil

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package grpcserverutil contains utilities for running gRPC servers.

TODO(reddaly): Rename package gcputil.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialSecure

func DialSecure[T any](ctx context.Context, addr string, factory func(conn *grpc.ClientConn) (T, error)) (T, error)

DialSecure dials a gRPC service securely using the system cert pool and calls the factory method to construct a client.

func ServeUntilCancelled

func ServeUntilCancelled(ctx context.Context, server *grpc.Server, lis net.Listener) error

ServeUntilCancelled calls server.Serve until the provided context is cancelled. When cancellation occurs, server.GracefulStop is called.

func SystemTLSCredentials

func SystemTLSCredentials() (credentials.TransportCredentials, error)

SystemTLSCredentials returns the standard transport credentials for connecting to a TLS server.

Types

type Address

type Address[ClientT any] struct {
	// contains filtered or unexported fields
}

Address is primarily used for defining flags that can be used to instantiate gRPC clients.

func AddressFlag

func AddressFlag[ClientT any](
	name string,
	defaultVal string,
	usage string,
	factory func(ctx context.Context, conn *grpc.ClientConn) (ClientT, error)) *Address[ClientT]

AddressFlag defines a new flag of type Address[ClientT].

func RegisterAddressFlag

func RegisterAddressFlag[ClientT any](
	fs *flag.FlagSet,
	name string,
	defaultVal string,
	usage string,
	factory func(ctx context.Context, conn *grpc.ClientConn) (ClientT, error)) *Address[ClientT]

RegisterAddressFlag defines a new flag of type Address[ClientT].

func (*Address[ClientT]) Dial

func (a *Address[ClientT]) Dial(ctx context.Context, opts ...grpc.DialOption) (ClientT, error)

Dial creates a new connection to the provided address and returns a client that uses that connection.

Jump to

Keyboard shortcuts

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