Documentation ¶
Index ¶
- Constants
- Variables
- func GetNamespace() string
- func GetPodName() string
- func LoadNamespace() string
- type ErrorHandleResource
- type Iterator
- type Registry
- func (s *Registry) Close()
- func (s *Registry) Deregister(ctx context.Context, _ *registry.ServiceInstance) error
- func (s *Registry) GetService(ctx context.Context, name string) ([]*registry.ServiceInstance, error)
- func (s *Registry) Register(ctx context.Context, service *registry.ServiceInstance) error
- func (s *Registry) Start()
- func (s *Registry) Watch(ctx context.Context, name string) (registry.Watcher, error)
Constants ¶
const ( // LabelsKeyServiceID is used to define the ID of the service LabelsKeyServiceID = "gomicro-service-id" // LabelsKeyServiceName is used to define the name of the service LabelsKeyServiceName = "gomicro-service-app" // LabelsKeyServiceVersion is used to define the version of the service LabelsKeyServiceVersion = "gomicro-service-version" // AnnotationsKeyMetadata is used to define the metadata of the service AnnotationsKeyMetadata = "gomicro-service-metadata" // AnnotationsKeyProtocolMap is used to define the protocols of the service // Through the value of this field, GoMicro can obtain the application layer protocol corresponding to the port // Example value: {"8080": "http", "9090": "grpc"} AnnotationsKeyProtocolMap = "gomicro-service-protocols" )
const ServiceAccountNamespacePath = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
ServiceAccountNamespacePath defines the location of the namespace file
Variables ¶
var ErrIteratorClosed = errors.New("iterator closed")
ErrIteratorClosed defines the error that the iterator is closed
Functions ¶
func GetNamespace ¶
func GetNamespace() string
GetNamespace is used to get the namespace of the Pod where the current container is located
func GetPodName ¶
func GetPodName() string
GetPodName is used to get the name of the Pod where the current container is located
func LoadNamespace ¶
func LoadNamespace() string
LoadNamespace is used to get the current namespace from the file
Types ¶
type ErrorHandleResource ¶
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
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
The Registry simply implements service discovery based on Kubernetes
func NewRegistry ¶
func NewRegistry(clientSet *kubernetes.Clientset) *Registry
NewRegistry is used to initialize the Registry
func (*Registry) Close ¶
func (s *Registry) Close()
Close is used to close the Registry After closing, any callbacks generated by Watch will not be executed
func (*Registry) Deregister ¶
Deregister the registration.
func (*Registry) GetService ¶
func (s *Registry) GetService(ctx context.Context, name string) ([]*registry.ServiceInstance, error)
GetService return the service instances in memory according to the service name.