|
|
@ -108,7 +108,7 @@ func NewRegistry(clientSet *kubernetes.Clientset) *Registry { |
|
|
|
// Register is used to register services
|
|
|
|
// Register is used to register services
|
|
|
|
// Note that on Kubernetes, it can only be used to update the id/name/version/metadata/protocols of the current service,
|
|
|
|
// Note that on Kubernetes, it can only be used to update the id/name/version/metadata/protocols of the current service,
|
|
|
|
// but it cannot be used to update node.
|
|
|
|
// but it cannot be used to update node.
|
|
|
|
func (s *Registry) Register(service *registry.ServiceInstance) error { |
|
|
|
func (s *Registry) Register(ctx context.Context, service *registry.ServiceInstance) error { |
|
|
|
// GetMetadata
|
|
|
|
// GetMetadata
|
|
|
|
metadataVal, err := marshal(service.Metadata) |
|
|
|
metadataVal, err := marshal(service.Metadata) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -145,15 +145,15 @@ func (s *Registry) Register(service *registry.ServiceInstance) error { |
|
|
|
if _, err = s.clientSet. |
|
|
|
if _, err = s.clientSet. |
|
|
|
CoreV1(). |
|
|
|
CoreV1(). |
|
|
|
Pods(GetNamespace()). |
|
|
|
Pods(GetNamespace()). |
|
|
|
Patch(context.TODO(), GetPodName(), types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}); err != nil { |
|
|
|
Patch(ctx, GetPodName(), types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Deregister the registration.
|
|
|
|
// Deregister the registration.
|
|
|
|
func (s *Registry) Deregister(service *registry.ServiceInstance) error { |
|
|
|
func (s *Registry) Deregister(ctx context.Context, service *registry.ServiceInstance) error { |
|
|
|
return s.Register(®istry.ServiceInstance{ |
|
|
|
return s.Register(ctx, ®istry.ServiceInstance{ |
|
|
|
Metadata: map[string]string{}, |
|
|
|
Metadata: map[string]string{}, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|