kubernetes

package
v0.0.0-...-157c77b Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LabelsKeyServiceID is used to define the ID of the service
	LabelsKeyServiceID = "kratos-service-id"
	// LabelsKeyServiceName is used to define the name of the service
	LabelsKeyServiceName = "kratos-service-app"
	// LabelsKeyServiceVersion is used to define the version of the service
	LabelsKeyServiceVersion = "kratos-service-version"
	// AnnotationsKeyMetadata is used to define the metadata of the service
	AnnotationsKeyMetadata = "kratos-service-metadata"
	// AnnotationsKeyProtocolMap is used to define the protocols of the service
	// Through the value of this field, Kratos can obtain the application layer protocol corresponding to the port
	// Example value: {"80": "http", "8081": "grpc"}
	AnnotationsKeyProtocolMap = "kratos-service-protocols"
)

Variables

View Source
var ErrIteratorClosed = errors.New("iterator closed")

ErrIteratorClosed defines the error that the iterator is closed

Functions

This section is empty.

Types

type ErrorHandleResource

type ErrorHandleResource struct {
	Namespace string
	Name      string
	Reason    error
}

ErrorHandleResource defines the error that cannot handle K8S resources normally

func (*ErrorHandleResource) Error

func (err *ErrorHandleResource) Error() string

Error implements the error interface

type Iterator

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

Iterator performs the conversion from channel to iterator It reads the latest changes from the `chan []*registry.ServiceInstance` And the outside can sense the closure of Iterator through stopCh

func NewIterator

func NewIterator(channel chan []*registry.ServiceInstance, stopCh chan struct{}) *Iterator

NewIterator is used to initialize Iterator

func (*Iterator) Next

func (iter *Iterator) Next() ([]*registry.ServiceInstance, error)

Next will block until ServiceInstance changes

func (*Iterator) Stop

func (iter *Iterator) Stop() error

Stop is used to close the iterator

type KubernetesDiscovery

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

func NewKubernetesDiscovery

func NewKubernetesDiscovery(options *regOps.DiscoveryOptions) (*KubernetesDiscovery, error)

func (*KubernetesDiscovery) Close

func (d *KubernetesDiscovery) Close()

Close is used to close the Registry After closing, any callbacks generated by Watch will not be executed

func (*KubernetesDiscovery) GetService

func (d *KubernetesDiscovery) GetService(ctx context.Context, name string) ([]*registry.ServiceInstance, error)

GetService return the service instances in memory according to the service name.

func (*KubernetesDiscovery) Start

func (d *KubernetesDiscovery) Start()

Start is used to start the Registry It is non-blocking

func (*KubernetesDiscovery) Watch

Watch creates a watcher according to the service name.

Jump to

Keyboard shortcuts

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