server

package
v0.13.9 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: Apache-2.0 Imports: 19 Imported by: 15

Documentation

Overview

Package server provides an implementation of a streaming xDS server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callbacks

type Callbacks interface {
	// OnStreamOpen is called once an xDS stream is open with a stream ID and the type URL (or "" for ADS).
	OnStreamOpen(int64, string)
	// OnStreamClosed is called immediately prior to closing an xDS stream with a stream ID.
	OnStreamClosed(int64)
	// OnStreamRequest is called once a request is received on a stream.
	OnStreamRequest(int64, *v2.DiscoveryRequest)
	// OnStreamResponse is called immediately prior to sending a response on a stream.
	OnStreamResponse(int64, *v2.DiscoveryRequest, *v2.DiscoveryResponse)
	// OnFetchRequest is called for each Fetch request
	OnFetchRequest(*v2.DiscoveryRequest)
	// OnFetchResponse is called immediately prior to sending a response.
	OnFetchResponse(*v2.DiscoveryRequest, *v2.DiscoveryResponse)
}

Callbacks is a collection of callbacks inserted into the server operation. The callbacks are invoked synchronously.

type HTTPGateway

type HTTPGateway struct {
	// Log is an optional log for errors in response write
	Log log.Logger

	// Server is the underlying gRPC server
	Server Server

	UrlToType map[string]string
}

HTTPGateway is a custom implementation of [gRPC gateway](https://github.com/grpc-ecosystem/grpc-gateway) specialized to Envoy xDS API.

func NewHTTPGateway

func NewHTTPGateway(log log.Logger, srv Server, urlToType ...map[string]string) *HTTPGateway

func (*HTTPGateway) ServeHTTP

func (h *HTTPGateway) ServeHTTP(resp http.ResponseWriter, req *http.Request)

type Server

type Server interface {
	discovery.AggregatedDiscoveryServiceServer

	// Fetch is the universal fetch method.
	Fetch(context.Context, *v2.DiscoveryRequest) (*v2.DiscoveryResponse, error)
	Stream(stream Stream, typeURL string) error
}

Server is a collection of handlers for streaming discovery requests.

func NewServer

func NewServer(config cache.Cache, callbacks Callbacks) Server

NewServer creates handlers from a config watcher and an optional logger.

type Stream

type Stream interface {
	Send(*v2.DiscoveryResponse) error
	Recv() (*v2.DiscoveryRequest, error)
	grpc.ServerStream
}

type TypedResponse

type TypedResponse struct {
	Response *cache.Response
	TypeUrl  string
}

Jump to

Keyboard shortcuts

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