package server

import "google.golang.org/grpc/xds/internal/server"

Package server contains internal server-side functionality used by the public facing xds package.

Index

Functions

func NewListenerWrapper

func NewListenerWrapper(params ListenerWrapperParams) (net.Listener, <-chan struct{})

NewListenerWrapper creates a new listenerWrapper with params. It returns a net.Listener and a channel which is written to, indicating that the former is ready to be passed to grpc.Serve().

Only TCP listeners are supported.

Types

type ListenerWrapperParams

type ListenerWrapperParams struct {
	// Listener is the net.Listener passed by the user that is to be wrapped.
	Listener net.Listener
	// ListenerResourceName is the xDS Listener resource to request.
	ListenerResourceName string
	// XDSCredsInUse specifies whether or not the user expressed interest to
	// receive security configuration from the control plane.
	XDSCredsInUse bool
	// XDSClient provides the functionality from the xdsClient required here.
	XDSClient XDSClientInterface
	// ModeCallback is the callback to invoke when the serving mode changes.
	ModeCallback ServingModeCallback
}

ListenerWrapperParams wraps parameters required to create a listenerWrapper.

type ServingMode

type ServingMode int

ServingMode indicates the current mode of operation of the server.

This API exactly mirrors the one in the public xds package. We have to redefine it here to avoid a cyclic dependency.

const (
	// ServingModeStarting indicates that the serving is starting up.
	ServingModeStarting ServingMode = iota
	// ServingModeServing indicates the the server contains all required xDS
	// configuration is serving RPCs.
	ServingModeServing
	// ServingModeNotServing indicates that the server is not accepting new
	// connections. Existing connections will be closed gracefully, allowing
	// in-progress RPCs to complete. A server enters this mode when it does not
	// contain the required xDS configuration to serve RPCs.
	ServingModeNotServing
)

func (ServingMode) String

func (s ServingMode) String() string

type ServingModeCallback

type ServingModeCallback func(addr net.Addr, mode ServingMode, err error)

ServingModeCallback is the callback that users can register to get notified about the server's serving mode changes. The callback is invoked with the address of the listener and its new mode. The err parameter is set to a non-nil error if the server has transitioned into not-serving mode.

type XDSClientInterface

type XDSClientInterface interface {
	WatchListener(string, func(xdsclient.ListenerUpdate, error)) func()
	BootstrapConfig() *bootstrap.Config
}

XDSClientInterface wraps the methods on the xdsClient which are required by the listenerWrapper.

Source Files

conn_wrapper.go listener_wrapper.go

Version
v1.38.1
Published
Jun 29, 2021
Platform
linux/amd64
Imports
14 packages
Last checked
2 minutes ago

Tools for package owners.