Skip to content

Commit

Permalink
Merge pull request #36 from little-cui/err
Browse files Browse the repository at this point in the history
Add discovery framework model
  • Loading branch information
tianxiaoliang committed Jun 30, 2021
2 parents 7681f1c + 98b6e31 commit b9201ba
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
36 changes: 36 additions & 0 deletions discovery/framework.go
Original file line number Diff line number Diff line change
@@ -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
*
* https://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
}
2 changes: 1 addition & 1 deletion discovery/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

// 删除服务请求
Expand Down
5 changes: 0 additions & 5 deletions discovery/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit b9201ba

Please sign in to comment.