ConfigService

  • gRPC服务地址:/fusion.discoveryx.grpc.ConfigService
  • REST URL前缀:/fusion/discoveryx/v1/config

REST URL路径由 REST URL前缀 + 服务名组织,均使用 POST 方法的请求,JSON序例化格式。如查询配置接口访问地址为:POST /fusion/discoveryx/v1/config/QueryConfig。Protobuf与JSON格式转换请参阅: JSON 说明

GetConfig

gRPC

// 查询配置
rpc GetConfig (fusion.discoveryx.model.ConfigGet) returns (fusion.discoveryx.model.ConfigReply) {
}

请求

message ConfigGet {
    string namespace = 1;
    string data_id = 2;
    google.protobuf.StringValue group_name = 3;
}

响应

message ConfigReply {
    int32 status = 1;
    string message = 2;
    oneof data {
        ConfigItem config = 3;
        ConfigQueried queried = 4;
    }
}

oneofqueried字段将返回已注册实例信息,如下:

enum ConfigType {
    TEXT = 0;
    HOCON = 1;
    JSON = 2;
    YAML = 3;
    PROPERTIES = 4;
    INI = 5;
}

message ConfigBasic {
    string data_id = 1;
    string group_name = 2;
    ConfigType type = 3;
}
message ConfigQueried {
    repeated ConfigBasic configs = 1;
    string namespace = 2;
    int32 page = 3;
    int32 size = 4;
    int32 total_elements = 5;
}

PublishConfig

gRPC

// 发布配置
rpc PublishConfig (fusion.discoveryx.model.ConfigItem) returns (fusion.discoveryx.model.ConfigReply) {
}

请求

message ConfigItem {
    string namespace = 1;
    string data_id = 2;
    string group_name = 3;
    string content = 4;
    ConfigType type = 5;
    repeated string tags = 6;
}

响应

message ConfigReply {
    int32 status = 1;
    string message = 2;
    oneof data {
        ConfigItem config = 3;
        ConfigQueried queried = 4;
    }
}

RemoveConfig

gRPC

// 删除配置
rpc RemoveConfig (fusion.discoveryx.model.ConfigRemove) returns (fusion.discoveryx.model.ConfigReply) {
}

请求

message ConfigRemove {
    string namespace = 1;
    string data_id = 2;
}

响应

message ConfigReply {
    int32 status = 1;
    string message = 2;
    oneof data {
        ConfigItem config = 3;
        ConfigQueried queried = 4;
    }
}

ListenerConfig

gRPC

// 监听配置变化
rpc ListenerConfig (fusion.discoveryx.model.ConfigChangeListen) returns (stream fusion.discoveryx.model.ConfigChanged) {
}

请求

message ConfigChangeListen {
    string namespace = 1;
    string data_id = 2;
}

响应

message ConfigChanged {
    fusion.discoveryx.model.ConfigItem config = 1;
    ChangeType change_type = 2;
    int32 version = 3;
}
enum ChangeType {
    // 保存
    CHANGE_SAVE = 0;
    // 添加
    CHANGE_ADD = 1;
    // 删除
    CHANGE_REMOVE = 2;
}
在此文档中发现错误?该页面的源代码可以在 这里 找到。欢迎随时编辑并提交Pull Request。