Skip to content

Commit

Permalink
feat:support fetch service contract (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun authored Jan 8, 2024
1 parent 99fca05 commit b8983f9
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 68 deletions.
4 changes: 3 additions & 1 deletion api/v1/service_manage/request.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package v1;

import "service.proto";
import "contract.proto";

option go_package = "github.com/polarismesh/specification/source/go/api/v1/service_manage";
option java_package = "com.tencent.polaris.specification.api.v1.service.manage";
Expand Down Expand Up @@ -30,6 +31,7 @@ message DiscoverRequest {
DiscoverRequestType type = 1;
Service service = 2;
reserved 3 to 4;
DiscoverFilter Filter = 30;
DiscoverFilter Filter = 30;
ServiceContract service_contract = 31;
}

78 changes: 44 additions & 34 deletions source/go/api/v1/service_manage/request.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion source/java/polaris-specification/src/main/proto/code.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ enum Code {
InvalidFaultDetectName = 400901;
InvalidFaultDetectNamespace = 400902;
FaultDetectRuleExisted = 400903;
InvalidMatchRule = 400904;

// network relative codes
ServicesExistedMesh = 400170;
Expand Down Expand Up @@ -190,4 +191,4 @@ enum Code {

AuthTokenForbidden = 403001;
OperationRoleForbidden = 403002;
}
}
53 changes: 49 additions & 4 deletions source/java/polaris-specification/src/main/proto/config_file.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ syntax = "proto3";
package v1;

import "google/protobuf/wrappers.proto";
import "model.proto";
option go_package = "github.com/polarismesh/specification/source/go/api/v1/config_manage";
option java_package = "com.tencent.polaris.specification.api.v1.config.manage";
option java_outer_classname = "ConfigFileProto";


message ConfigFileGroup {
google.protobuf.UInt64Value id = 1;
google.protobuf.StringValue name = 2;
Expand Down Expand Up @@ -82,6 +82,9 @@ message ConfigFileRelease {
google.protobuf.BoolValue active = 15;
google.protobuf.StringValue format = 16;
google.protobuf.StringValue release_description = 17;
google.protobuf.StringValue release_type = 18;
// 配置灰度发布时需要匹配的客户端标签信息
repeated ClientLabel beta_labels = 19;
}

message ConfigFileReleaseHistory {
Expand Down Expand Up @@ -156,13 +159,55 @@ message ConfigFilePublishInfo {
google.protobuf.StringValue content = 5;
google.protobuf.StringValue comment = 6;
google.protobuf.StringValue format = 7;
google.protobuf.StringValue release_description = 8 [ json_name = "release_description" ];
google.protobuf.StringValue release_description = 8
[ json_name = "release_description" ];
google.protobuf.StringValue create_by = 11 [ json_name = "create_by" ];
google.protobuf.StringValue modify_by = 13 [ json_name = "modify_by" ];
repeated ConfigFileTag tags = 14;
google.protobuf.StringValue md5 = 15;
// 是否为加密配置文件
google.protobuf.BoolValue encrypted = 16;
// 加密算法
google.protobuf.StringValue encrypt_algo = 17;
}

message ConfigFileGroupRequest {
google.protobuf.StringValue revision = 1;
ConfigFileGroup config_file_group = 2;
}
ConfigFileGroup config_file_group = 2 [ json_name = "config_file_group" ];
// 配置标签
map<string, string> client_labels = 12 [ json_name = "client_labels" ];
}

message ConfigDiscoverRequest {
enum ConfigDiscoverRequestType {
UNKNOWN = 0;
CONFIG_FILE = 1;
CONFIG_FILE_Names = 2;
CONFIG_FILE_GROUPS = 3;
}
ConfigDiscoverRequestType type = 1;
ClientConfigFileInfo config_file = 2 [ json_name = "config_file" ];
string revision = 3;
}

message ConfigDiscoverResponse {
enum ConfigDiscoverResponseType {
UNKNOWN = 0;
CONFIG_FILE = 1;
CONFIG_FILE_Names = 2;
CONFIG_FILE_GROUPS = 3;
}

uint32 code = 1;
string info = 2;
string revision = 3;

ConfigDiscoverResponseType type = 4;

ClientConfigFileInfo config_file = 5 [ json_name = "config_file" ];

repeated ClientConfigFileInfo config_file_names = 6
[ json_name = "config_file_names" ];
repeated ConfigFileGroup config_file_groups = 7
[ json_name = "config_file_groups" ];
}
46 changes: 30 additions & 16 deletions source/java/polaris-specification/src/main/proto/contract.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,53 @@ option java_package = "com.tencent.polaris.specification.api.v1.service.manage";
option java_outer_classname = "ServiceContractProto";

message ServiceContract {
// 契约ID
string id = 1;
// 契约名称
string name = 1;
string name = 2;
// 所属命名空间
string namespace = 2;
string namespace = 3;
// 所属服务名称
string service = 3;
string service = 4;
// 协议,http/grpc/dubbo/thrift
string protocol = 4;
string protocol = 5;
// 契约版本
string version = 5;
string version = 6;
// 信息摘要
string revision = 6;
string revision = 7;
// 额外描述
string content = 7;
string content = 8;
// 接口描述信息
repeated InterfaceDescriptor interfaces = 8;
repeated InterfaceDescriptor interfaces = 9;
// 创建时间
string ctime = 9;
string ctime = 10;
// 更新时间
string mtime = 10;
string mtime = 11;
// 接口状态,Offline/Online
string status = 12;
}

message InterfaceDescriptor {
enum Source {
UNKNOWN = 0;
Manual = 1;
Client = 2;
}

// 接口ID
string id = 1;
// 方法名称,对应 http method/ dubbo interface func/grpc service func
string method = 1;
string method = 2;
// 接口名称,http path/dubbo interface/grpc service
string path = 2;
string path = 3;
// 接口描述信息
string content = 3;
string content = 4;
// 创建来源
Source source = 5;
// 接口信息摘要
string revision = 4;
string revision = 6;
// 创建时间
string ctime = 9;
string ctime = 7;
// 更新时间
string mtime = 10;
string mtime = 8;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ service PolarisConfigGRPC {
// 拉取指定配置分组下的配置文件列表
rpc GetConfigFileMetadataList(ConfigFileGroupRequest) returns (ConfigClientListResponse) {}

// 统一发现接口
rpc Discover(stream ConfigDiscoverRequest) returns (stream ConfigDiscoverResponse) {}
}
10 changes: 7 additions & 3 deletions source/java/polaris-specification/src/main/proto/grpcapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ service PolarisGRPC {
rpc Discover(stream DiscoverRequest) returns (stream DiscoverResponse) {}
// 被调方上报心跳
rpc Heartbeat(Instance) returns (Response) {}
// 上报服务契约
rpc ReportServiceContract(ServiceContract) returns (Response) {}
}

service PolarisHeartbeatGRPC {
// 被调方批量上报心跳
rpc BatchHeartbeat(stream HeartbeatsRequest) returns (stream HeartbeatsResponse) {}
rpc BatchHeartbeat(stream HeartbeatsRequest)
returns (stream HeartbeatsResponse) {}
// 批量获取心跳记录
rpc BatchGetHeartbeat(GetHeartbeatsRequest) returns (GetHeartbeatsResponse) {}
// 批量删除心跳记录
rpc BatchDelHeartbeat(DelHeartbeatsRequest) returns (DelHeartbeatsResponse) {}
}

service PolarisServiceContractGRPC {
// 上报服务契约
rpc ReportServiceContract(ServiceContract) returns (Response) {}
}
19 changes: 11 additions & 8 deletions source/java/polaris-specification/src/main/proto/model.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,23 @@ message MatchString {

MatchStringType type = 1;
google.protobuf.StringValue value = 2;
ValueType value_type = 3 [json_name = "value_type"];
ValueType value_type = 3 [ json_name = "value_type" ];
}


message StringList {
repeated string values = 1;
}
message StringList { repeated string values = 1; }

// 汇总查询数据
message Summary {
// 服务总数
uint32 total_service_count = 1 [json_name = "total_service_count"];
uint32 total_service_count = 1 [ json_name = "total_service_count" ];
// 健康实例总数
uint32 total_health_instance_count = 2 [json_name = "total_health_instance_count"];
uint32 total_health_instance_count = 2
[ json_name = "total_health_instance_count" ];
// 实例总数
uint32 total_instance_count = 3 [json_name = "total_instance_count"];
uint32 total_instance_count = 3 [ json_name = "total_instance_count" ];
}

message ClientLabel {
string key = 1;
MatchString value = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ message Namespace {
google.protobuf.StringValue id = 12;

google.protobuf.BoolValue editable = 15;

repeated google.protobuf.StringValue service_export_to = 16 [ json_name = "service_export_to" ];
}
Loading

0 comments on commit b8983f9

Please sign in to comment.