diff --git a/discovery/framework.go b/discovery/framework.go new file mode 100644 index 0000000..737b063 --- /dev/null +++ b/discovery/framework.go @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package discovery + +const Unknown = "UNKNOWN" + +type FrameWork struct { + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` +} + +func ToFrameworkLabel(ms *MicroService) (string, string) { + if ms.Framework != nil && len(ms.Framework.Name) > 0 { + version := ms.Framework.Version + if len(ms.Framework.Version) == 0 { + version = Unknown + } + return ms.Framework.Name, version + } + return Unknown, Unknown +} diff --git a/discovery/service.go b/discovery/service.go index 654d0e8..8342cb8 100644 --- a/discovery/service.go +++ b/discovery/service.go @@ -35,7 +35,7 @@ type MicroService struct { ModTimestamp string `protobuf:"bytes,15,opt,name=modTimestamp" json:"modTimestamp,omitempty" bson:"mod_timestamp"` Environment string `protobuf:"bytes,16,opt,name=environment" json:"environment,omitempty" bson:"env"` RegisterBy string `protobuf:"bytes,17,opt,name=registerBy" json:"registerBy,omitempty" bson:"register_by"` - Framework *FrameWorkProperty `protobuf:"bytes,18,opt,name=framework" json:"framework,omitempty"` + Framework *FrameWork `protobuf:"bytes,18,opt,name=framework" json:"framework,omitempty"` } // 删除服务请求 diff --git a/discovery/types.go b/discovery/types.go index 616f732..37c0f87 100644 --- a/discovery/types.go +++ b/discovery/types.go @@ -125,11 +125,6 @@ func (mk *MicroServiceKey) String() string { return fmt.Sprintf("&{%v %v %v %v %v %v}", mk.Tenant, mk.Environment, mk.AppId, mk.ServiceName, mk.Alias, mk.Version) } -type FrameWorkProperty struct { - Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` -} - type ServiceRule struct { RuleId string `protobuf:"bytes,1,opt,name=ruleId" json:"ruleId,omitempty" bson:"rule_id"` RuleType string `protobuf:"bytes,2,opt,name=ruleType" json:"ruleType,omitempty" bson:"rule_type"`