internal

package
v0.0.0-...-36ce7d1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 58 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(sl []string, str string) bool

func GenerateSnapshot

func GenerateSnapshot(node *core.Node, mapping Mapping) (*cache.Snapshot, error)

GenerateSnapshot creates snapshot for each service

func KubernetesEndpointWatch

func KubernetesEndpointWatch(ctx context.Context, fn func(watch.EventType, Slice)) error

func Namespace

func Namespace() string

Namespace provides some Kubernetes Magic: inside kubernetes the /var/run directory is populated with useful information Source: https://github.com/kubernetes/kubernetes/pull/63707#issuecomment-539648137

func Run

func Run(ctx context.Context, config *viper.Viper, d Discovery)

func RunManagementServer

func RunManagementServer(ctx context.Context, server xds.Server, port uint, maxConcurrentStreams uint32)

RunManagementServer starts an xDS server at the given port.

Types

type Callbacks

type Callbacks struct {
	Signal   chan struct{}
	Fetches  int
	Requests int
	// contains filtered or unexported fields
}

Callbacks for XD Server

func (*Callbacks) OnDeltaStreamClosed

func (cb *Callbacks) OnDeltaStreamClosed(id int64)

OnDeltaStreamClosed is called immediately prior to closing an xDS stream with a stream ID.

func (*Callbacks) OnDeltaStreamOpen

func (cb *Callbacks) OnDeltaStreamOpen(ctx context.Context, id int64, typ string) error

OnDeltaStreamOpen is called once an incremental xDS stream is open with a stream ID and the type URL (or "" for ADS). Returning an error will end processing and close the stream. OnStreamClosed will still be called.

func (*Callbacks) OnFetchRequest

func (cb *Callbacks) OnFetchRequest(ctx context.Context, req *discoveryv3.DiscoveryRequest) error

OnFetchRequest type

func (*Callbacks) OnFetchResponse

func (cb *Callbacks) OnFetchResponse(req *discoveryv3.DiscoveryRequest, resp *discoveryv3.DiscoveryResponse)

OnFetchResponse type

func (*Callbacks) OnStreamClosed

func (cb *Callbacks) OnStreamClosed(id int64)

OnStreamClosed type

func (*Callbacks) OnStreamDeltaRequest

func (cb *Callbacks) OnStreamDeltaRequest(id int64, req *discoveryv3.DeltaDiscoveryRequest) error

OnStreamDeltaRequest is called once a request is received on a stream. Returning an error will end processing and close the stream. OnStreamClosed will still be called.

func (*Callbacks) OnStreamDeltaResponse

func (cb *Callbacks) OnStreamDeltaResponse(id int64, req *discoveryv3.DeltaDiscoveryRequest, resp *discoveryv3.DeltaDiscoveryResponse)

OnStreamDelatResponse is called immediately prior to sending a response on a stream.

func (*Callbacks) OnStreamOpen

func (cb *Callbacks) OnStreamOpen(ctx context.Context, id int64, typ string) error

OnStreamOpen type

func (*Callbacks) OnStreamRequest

func (cb *Callbacks) OnStreamRequest(id int64, req *discoveryv3.DiscoveryRequest) error

OnStreamRequest type

func (*Callbacks) OnStreamResponse

func (cb *Callbacks) OnStreamResponse(ctx context.Context, id int64, req *discoveryv3.DiscoveryRequest, resp *discoveryv3.DiscoveryResponse)

OnStreamResponse type

func (*Callbacks) Report

func (cb *Callbacks) Report()

Report type

type Discovery

type Discovery interface {
	Start(ctx context.Context, upstreamServices []string) error
	Watch() <-chan Mapping
}

type DiscoveryImpl

type DiscoveryImpl struct {
	sync.Mutex

	Fn func(context.Context, func(t watch.EventType, s Slice)) error
	// contains filtered or unexported fields
}

DiscoveryImpl is a generic discovery layer that hooks to Fn. It generates and emits zoned mappings, by inspecting the Slice's Endpoint information.

func (*DiscoveryImpl) Emit

func (d *DiscoveryImpl) Emit(m Mapping)

func (*DiscoveryImpl) Start

func (d *DiscoveryImpl) Start(ctx context.Context, upstreamServices []string) error

func (*DiscoveryImpl) Watch

func (d *DiscoveryImpl) Watch() <-chan Mapping

Watch always emits the last computed value first, so the consumer can start immediately

type Endpoint

type Endpoint struct {
	Addresses  []string
	Ready      bool
	TargetName string
	Topology   Topology
}

func (*Endpoint) FromK8s

func (e *Endpoint) FromK8s(addr []string, ready *bool, targetName *string, host *string, zone *string)

type FilterCache

type FilterCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*FilterCache) CreateDeltaWatch

func (fc *FilterCache) CreateDeltaWatch(req *cache.DeltaRequest, ss stream.StreamState, resp chan cache.DeltaResponse) (cancel func())

func (*FilterCache) CreateWatch

func (fc *FilterCache) CreateWatch(req *cache.Request, ss stream.StreamState, resp chan cache.Response) (cancel func())

func (*FilterCache) Fetch

func (fc *FilterCache) Fetch(ctx context.Context, req *cache.Request) (cache.Response, error)

type Mapping

type Mapping = map[string]map[string][]podEndPoint

type MockDiscovery

type MockDiscovery struct {
	DiscoveryImpl
	// contains filtered or unexported fields
}

MockDiscovery 'discovers' from a file like mapping.yaml

func (*MockDiscovery) Start

func (d *MockDiscovery) Start(ctx context.Context, upstreamServices []string) error

type Paths

type Paths struct{ Paths []string }

func (Paths) Has

func (p Paths) Has(api string) bool

type Port

type Port struct {
	Name     string
	Protocol string
	Port     int32
}

func (*Port) FromK8s

func (port *Port) FromK8s(Name *string, Port *int32, Protocol *string)

type Slice

type Slice struct {
	Name        string
	Service     string
	AddressType string // IPv4 IPv6
	Endpoints   []Endpoint
	Ports       []Port
}

func (*Slice) FromV1

func (slice *Slice) FromV1(es *v1.EndpointSlice)

func (*Slice) FromV1Beta1

func (slice *Slice) FromV1Beta1(es *v1beta1.EndpointSlice)

type Topology

type Topology struct {
	Host string
	Zone string
}

Jump to

Keyboard shortcuts

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