style(contrib/registry/*) annotation perfect (#2185)

Co-authored-by: xiongpan828@qq.com <panxiong@aithu.com>
pull/2085/head
潘雄 2 years ago committed by GitHub
parent d0a0edf67b
commit 96c8de9bc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      contrib/registry/eureka/client.go
  2. 4
      contrib/registry/eureka/register.go
  3. 8
      contrib/registry/kubernetes/registry.go

@ -37,7 +37,7 @@ type Endpoint struct {
MetaData map[string]string
}
// Response for /eureka/apps
// ApplicationsRootResponse for /eureka/apps
type ApplicationsRootResponse struct {
ApplicationsResponse `json:"applications"`
}

@ -59,7 +59,7 @@ func New(eurekaUrls []string, opts ...Option) (*Registry, error) {
return r, nil
}
// 这里的Context是每个注册器独享的
// Register 这里的Context是每个注册器独享的
func (r *Registry) Register(ctx context.Context, service *registry.ServiceInstance) error {
return r.api.Register(ctx, service.Name, r.Endpoints(service)...)
}
@ -86,7 +86,7 @@ func (r *Registry) GetService(ctx context.Context, serviceName string) ([]*regis
return items, nil
}
// watch 是独立的ctx
// Watch 是独立的ctx
func (r *Registry) Watch(ctx context.Context, serviceName string) (registry.Watcher, error) {
return newWatch(ctx, r.api, serviceName)
}

@ -1,4 +1,4 @@
// The package registry simply implements the Kubernetes-based Registry
// Package kuberegistry registry simply implements the Kubernetes-based Registry
package kuberegistry
import (
@ -78,7 +78,7 @@ const (
AnnotationsKeyProtocolMap = "kratos-service-protocols"
)
// The registry simply implements service discovery based on Kubernetes
// The Registry simply implements service discovery based on Kubernetes
// It has not been verified in the production environment and is currently for reference only
type Registry struct {
clientSet *kubernetes.Clientset
@ -156,7 +156,7 @@ func (s *Registry) Deregister(ctx context.Context, service *registry.ServiceInst
})
}
// Service return the service instances in memory according to the service name.
// GetService return the service instances in memory according to the service name.
func (s *Registry) GetService(ctx context.Context, name string) ([]*registry.ServiceInstance, error) {
pods, err := s.podLister.List(labels.SelectorFromSet(map[string]string{
LabelsKeyServiceName: name,
@ -258,7 +258,7 @@ func GetNamespace() string {
return currentNamespace
}
// GetNamespace is used to get the name of the Pod where the current container is located
// GetPodName is used to get the name of the Pod where the current container is located
func GetPodName() string {
return os.Getenv("HOSTNAME")
}

Loading…
Cancel
Save