grpcutil

package
v0.30.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGRPCContextCanceled

func IsGRPCContextCanceled(err error) bool

IsGRPCContextCanceled returns whether the input error is a GRPC error wrapping the context.Canceled error.

Types

type HealthCheck

type HealthCheck struct {
	// contains filtered or unexported fields
}

HealthCheck fulfills the grpc_health_v1.HealthServer interface by ensuring the services being managed by the provided service manager are healthy.

func NewHealthCheck

func NewHealthCheck(sm *services.Manager) *HealthCheck

NewHealthCheck returns a new HealthCheck for the provided service manager.

func (*HealthCheck) Check

Check implements the grpc healthcheck.

func (*HealthCheck) Watch

Watch implements the grpc healthcheck.

type Operation

type Operation uint8

Operation defines the corresponding operations for a name resolution change.

const (
	// Add indicates a new address is added.
	Add Operation = iota
	// Delete indicates an existing address is deleted.
	Delete
)

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver handles name resolution for names following the DNS scheme.

func NewDNSResolver

func NewDNSResolver(logger log.Logger) (*Resolver, error)

NewDNSResolver creates a DNS Resolver that can resolve DNS names, and create watchers that poll the DNS server using the default frequency defined by defaultFreq.

func NewDNSResolverWithFreq

func NewDNSResolverWithFreq(freq time.Duration, logger log.Logger) (*Resolver, error)

NewDNSResolverWithFreq creates a DNS Resolver that can resolve DNS names, and create watchers that poll the DNS server using the frequency set by freq.

func (*Resolver) Resolve

func (r *Resolver) Resolve(target, service string) (Watcher, error)

Resolve creates a watcher that watches the SRV/hostname record resolution of the target.

If service is not empty, the watcher will first attempt to resolve an SRV record. If that fails, or service is empty, hostname record resolution is attempted instead. If target can be parsed as an IP address, the watcher will return it, and will not send any more updates afterwards.

type Update

type Update struct {
	// Op indicates the operation of the update.
	Op Operation
	// Addr is the updated address. It is empty string if there is no address update.
	Addr string
	// Metadata is the updated metadata. It is nil if there is no metadata update.
	// Metadata is not required for a custom naming implementation.
	Metadata interface{}
}

Update defines a name resolution update. Notice that it is not valid having both empty string Addr and nil Metadata in an Update.

type Watcher

type Watcher interface {
	// Next blocks until an update or error happens. It may return one or more
	// updates. The first call should get the full set of the results. It should
	// return an error if and only if Watcher cannot recover.
	Next() ([]*Update, error)
	// Close closes the Watcher.
	Close()
}

Watcher watches for SRV updates on the specified target.

Jump to

Keyboard shortcuts

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