grpcutil

package
v1.18.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPHeaderPropagationClientInterceptor added in v1.14.0

func HTTPHeaderPropagationClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
	invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

HTTPHeaderPropagationClientInterceptor allows for propagation of HTTP Request headers across gRPC calls - works alongside HTTPHeaderPropagationServerInterceptor

func HTTPHeaderPropagationServerInterceptor added in v1.14.0

func HTTPHeaderPropagationServerInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

HTTPHeaderPropagationServerInterceptor allows for propagation of HTTP Request headers across gRPC calls - works alongside HTTPHeaderPropagationClientInterceptor

func HTTPHeaderPropagationStreamClientInterceptor added in v1.14.0

func HTTPHeaderPropagationStreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string,
	streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)

HTTPHeaderPropagationStreamClientInterceptor does the same as HTTPHeaderPropagationClientInterceptor but for streams

func HTTPHeaderPropagationStreamServerInterceptor added in v1.14.0

func HTTPHeaderPropagationStreamServerInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error

HTTPHeaderPropagationStreamServerInterceptor does the same as HTTPHeaderPropagationServerInterceptor but for streams

func IsGRPCContextCanceled added in v1.13.0

func IsGRPCContextCanceled(err error) bool

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

Types

type HealthCheck added in v1.13.0

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 added in v1.13.0

func NewHealthCheck(sm *services.Manager) *HealthCheck

NewHealthCheck returns a new HealthCheck for the provided service manager.

func (*HealthCheck) Check added in v1.13.0

Check implements the grpc healthcheck.

func (*HealthCheck) Watch added in v1.13.0

Watch implements the grpc healthcheck.

type Operation added in v1.13.0

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 added in v1.13.0

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

Resolver handles name resolution for names following the DNS scheme.

func NewDNSResolver added in v1.13.0

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 added in v1.13.0

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 added in v1.13.0

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 added in v1.13.0

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 added in v1.13.0

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