syntax = "proto3";
option java_multiple_files = false;
option java_package = "com.actiontech.dble.cluster.general.impl.ushard";
option java_outer_classname = "UshardInterface";
option objc_class_prefix = "ushard";

package ushard;

service DbleCluster {

    rpc PutKv (PutKvInput) returns (Empty) {
    }

    rpc GetKv (GetKvInput) returns (GetKvOutput) {
    }

    rpc DeleteKv (DeleteKvInput) returns (Empty) {
    }

    rpc DeleteKvTree (DeleteKvTreeInput) returns (Empty) {
    }

    rpc SubscribeKvPrefix (SubscribeKvPrefixInput) returns (SubscribeKvPrefixOutput) {
    }

    rpc GetKvTree (GetKvTreeInput) returns (GetKvTreeOutput) {
    }

    rpc Alert (AlertInput) returns (Empty) {
    }

    rpc AlertResolve (AlertInput) returns (Empty) {
    }

    rpc LockOnSession (LockOnSessionInput) returns (LockOnSessionOutput) {
    }

    rpc RenewSession (RenewSessionInput) returns (Empty) {
    }

    rpc UnlockOnSession (UnlockOnSessionInput) returns (Empty) {
    }

}

message Empty {
}

message PutKvInput {
    string Key = 1;
    string Value = 2;
}

message GetKvInput {
    string Key = 1;
}

message GetKvOutput {
    string Value = 1;
}

message DeleteKvInput {
    string Key = 1;
}

message DeleteKvTreeInput {
    string Key = 1;
}

message SubscribeKvPrefixInput {
    string KeyPrefix = 1;
    uint64 Index = 2;
    uint32 Duration = 3;
}

message SubscribeKvPrefixOutput {
    uint64 Index = 1;
    repeated string Keys = 2;
    repeated string Values = 3;
}

message GetKvTreeInput {
    string Key = 1;
}

message GetKvTreeOutput {
    uint64 Index = 1;
    repeated string Keys = 2;
    repeated string Values = 3;
}

message AlertInput {
    string Code = 1;
    string Level = 2;
    string Desc = 3;
    string SourceComponentType = 4;
    string SourceComponentId = 5;
    string AlertComponentType = 6;
    string AlertComponentId = 7;
    string ServerId = 8;
    map<string, string> Labels = 9;
    map<string, string> Annotations = 10;
    int64 TimestampUnix = 11;
    int64 ResolveTimestampUnix = 12;
}


message LockOnSessionInput {
    string Key = 1;
    string Value = 2;
    uint64 TTLSeconds = 3;
}


message LockOnSessionOutput {
    bool Locked = 1;
    string SessionId = 2;
}

message RenewSessionInput {
    string SessionId = 1;
}

message UnlockOnSessionInput {
    string Key = 1;
    string SessionId = 2;
}
