kubernetes

package
v3.0.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// all pod annotation key
	DubboIOAnnotationKey = "dubbo.io/annotation"
	// all pod label key and value pair
	DubboIOLabelKey           = "dubbo.io/label"
	DubboIOConsumerLabelValue = "dubbo.io.consumer"
	DubboIOProviderLabelValue = "dubbo.io.provider"
)
View Source
const (
	Create eventType = iota
	Update
	Delete
)

Variables

View Source
var (
	ErrWatcherSetAlreadyStopped = perrors.New("the watcher-set already be stopped")
	ErrKVPairNotFound           = perrors.New("k/v pair not found")
)
View Source
var ErrDubboLabelAlreadyExist = perrors.New("dubbo label already exist")

Functions

func GetInClusterKubernetesClient

func GetInClusterKubernetesClient() (kubernetes.Interface, error)

GetInClusterKubernetesClient current pod running in kubernetes-cluster

func ValidateClient

func ValidateClient(container clientFacade) error

ValidateClient validates the kubernetes client

Types

type Client

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

func NewClient

func NewClient(url *common.URL) (*Client, error)

NewClient returns Client instance for registry

func NewMockClient

func NewMockClient(podList *v1.PodList) (*Client, error)

NewMockClient exports for registry package test

func (*Client) Close

func (c *Client) Close()

nolint

func (*Client) Create

func (c *Client) Create(k, v string) error

Create creates k/v pair in watcher-set

func (*Client) Done

func (c *Client) Done() <-chan struct{}

nolint

func (*Client) GetChildren

func (c *Client) GetChildren(k string) ([]string, []string, error)

GetChildren gets k children list from kubernetes-watcherSet

func (*Client) SetLabel

func (c *Client) SetLabel(k, v string) error

func (*Client) Valid

func (c *Client) Valid() bool

if returns false, the client is die

func (*Client) Watch

func (c *Client) Watch(k string) (<-chan *WatcherEvent, <-chan struct{}, error)

Watch watches on spec key

func (*Client) WatchWithPrefix

func (c *Client) WatchWithPrefix(prefix string) (<-chan *WatcherEvent, <-chan struct{}, error)

WatchWithPrefix watches on spec prefix

type EventListener

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

func NewEventListener

func NewEventListener(client *Client) *EventListener

func (*EventListener) Close

func (l *EventListener) Close()

func (*EventListener) ListenServiceEvent

func (l *EventListener) ListenServiceEvent(key string, listener remoting.DataListener)

this func is invoked by kubernetes ConsumerRegistry::Registry/ kubernetes ConsumerRegistry::get/kubernetes ConsumerRegistry::getListener registry.go:Listen -> listenServiceEvent -> listenDirEvent -> ListenServiceNodeEvent

|
--------> ListenServiceNodeEvent

func (*EventListener) ListenServiceNodeEvent

func (l *EventListener) ListenServiceNodeEvent(key string, listener ...remoting.DataListener) bool

Listen on a spec key this method returns true when spec key deleted, this method returns false when deep layer connection lose

func (*EventListener) ListenServiceNodeEventWithPrefix

func (l *EventListener) ListenServiceNodeEventWithPrefix(prefix string, listener ...remoting.DataListener)

Listen on a set of key with spec prefix

type Watcher

type Watcher interface {
	// the watcher's id
	ID() string
	// result stream
	ResultChan() <-chan *WatcherEvent
	// contains filtered or unexported methods
}

Watcher

type WatcherEvent

type WatcherEvent struct {
	// event-type
	EventType eventType `json:"-"`
	// the dubbo-go should consume the key
	Key string `json:"k"`
	// the dubbo-go should consume the value
	Value string `json:"v"`
}

WatcherEvent watch event is element in watcherSet

type WatcherSet

type WatcherSet interface {

	// put the watch event to the watch set
	Put(object *WatcherEvent) error
	// if prefix is false,
	// the len([]*WatcherEvent) == 1
	Get(key string, prefix bool) ([]*WatcherEvent, error)
	// watch the spec key or key prefix
	Watch(key string, prefix bool) (Watcher, error)
	// check the watcher set status
	Done() <-chan struct{}
}

Watchable WatcherSet thread-safe

Jump to

Keyboard shortcuts

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