example

package
v0.0.0-...-f1a479f Latest Latest
Warning

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

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

README

Example xDS Server: go-control-plane

This is an example of a trivial xDS V3 control plane server, that uses envoy's go control plane. It implements the xds-test-harness adapter for setting and updating the server state. It is not meant as an actual envoy control plane, and maintains just a simple snapshot state.

To run it, from the root of this repo, invoke:

go run examples/go-control-plane/main.go

Once it is running, you can run the test suite in a separate window with:

go run .

Files

  • main/main.go is the example program entrypoint. It instantiates the cache and xDS server and runs the xDS server process.
  • adapter.go implementation of the adapter api.
  • server.go runs the xDS control plane server.
  • logger.go implements the pkg/log/Logger interface which provides logging services to the cache.

Documentation

Overview

Copyright 2020 Envoyproxy Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2020 Envoyproxy Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Index

Constants

View Source
const (
	TypeUrlLDS = "type.googleapis.com/envoy.config.listener.v3.Listener"
	TypeUrlCDS = "type.googleapis.com/envoy.config.cluster.v3.Cluster"
	TypeUrlRDS = "type.googleapis.com/envoy.config.route.v3.RouteConfiguration"
	TypeUrlEDS = "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment"
)

Variables

This section is empty.

Functions

func MakeCluster

func MakeCluster(clusterName string, node string) *cluster.Cluster

func MakeEndpoint

func MakeEndpoint(clusterName string, address string, port uint32) *endpoint.ClusterLoadAssignment

MakeEndpoint creates a localhost endpoint on a given port.

func MakeRoute

func MakeRoute(routeName, clusterName string) *route.RouteConfiguration

func MakeRouteHTTPListener

func MakeRouteHTTPListener(clusterName string, listenerName string, listenerAddress string, port uint32, route string) *listener.Listener

func MakeRuntime

func MakeRuntime(runtimeName string) *runtime.Runtime

MakeRuntime creates an RTDS layer with some fields.

func RunAdapter

func RunAdapter(port uint, cache cache.SnapshotCache)

func RunServer

func RunServer(ctx context.Context, srv server.Server, port uint)

RunServer starts an xDS server at the given port.

Types

type Clusters

type Clusters map[string]*cluster.Cluster

type Endpoints

type Endpoints map[string]*endpoint.ClusterLoadAssignment

type Listeners

type Listeners map[string]*listener.Listener

type Logger

type Logger struct {
	Debug bool
}

An example of a logger that implements `pkg/log/Logger`. Logs to stdout. If Debug == false then Debugf() and Infof() won't output anything.

func (Logger) Debugf

func (logger Logger) Debugf(format string, args ...interface{})

Log to stdout only if Debug is true.

func (Logger) Errorf

func (logger Logger) Errorf(format string, args ...interface{})

Log to stdout always.

func (Logger) Infof

func (logger Logger) Infof(format string, args ...interface{})

Log to stdout only if Debug is true.

func (Logger) Warnf

func (logger Logger) Warnf(format string, args ...interface{})

Log to stdout always.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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