package NSaasProto;

message TSlot {
    required string Host = 2;
    required uint32 Port = 3;
}

message TMetaLink {
    required TSlot Slot = 1;
    optional bool Enabled = 3 [default = true] ;
}

message TMetaSlot {
    required TSlot Slot = 1;
    optional bool Enabled = 2 [default = true] ;
    repeated TMetaLink Sources = 3;
}

message TRTYSlot {
    required TSlot Slot = 1;
    optional uint32 ShardMin = 2;
    optional uint32 ShardMax = 3;
    optional uint32 IndexingPort = 4 [default = 1];
    optional bool DisableSearch = 5 [default = false];
    optional bool DisableIndexing = 6 [default = false];
    optional bool DisableSearchFiltration = 7 [default = false];
    optional bool DisableFetch = 8 [default = false];
    optional string Group = 9;
    optional string DC = 10;
    optional bool IsSD = 11 [default = false];
}

message TSlotsPool {
    repeated TRTYSlot Slots = 1;
    repeated TRTYSlot EndPointSets = 2;
}

message TConfigType {
    required string Name = 1;
    optional string Features = 2;
    optional uint32 UpdateFrequency = 3;
    optional bool DisableSearch = 4 [default = false];
    optional bool DisableIndexing = 7 [default = false];
    optional TSlotsPool Slots = 8;
}

message TService {
    enum EShardingType{
        KeyPrefix = 0;
        UrlHash = 1;
        External = 3;
        Broadcast = 4;
        Geo = 5;
        GeoRestrict = 6;
        UrlHashErasure = 7;
        QuerySearch = 8;
        UrlToLastOctothorp = 9;
        UrlToLastUnderscore = 10;
    }
    enum EDispatchTarget {
        Distributor = 0;
        Backends = 1;
        Void = 2;
        PersQueue = 3;
    }
    enum EShardsCount {
        Legacy = 1;
        UI32 = 2;
    }
    message TAliasesWeight {
        required string From = 1;
        required string To = 2;
        required uint32 Weight = 3;
    }
    required string Name = 1;
    optional bool RequireAuth = 2 [default = false];
    optional string SearchProtocol = 3 [default = "proto"];
    optional EShardingType ShardBy = 4 [default = KeyPrefix];
    optional string StorageType = 5 [default = "no", deprecated = true];
    optional EDispatchTarget IndexingTarget = 6 [default = Backends];
    optional string Distributors = 7 [default = ""];
    optional string Stream = 8 [default = ""];
    optional bool PerDcSearch = 9 [default = false];
    optional uint32 NumPartitions = 14 [deprecated = true];
    optional uint32 NumTopics = 15 [default = 0];
    optional bool SkipPing = 16;

    repeated TConfigType ConfigType = 10;
    optional uint32 KpsShift = 11 [default = 0];
    optional EShardsCount Shards = 12 [default = Legacy];
    repeated TAliasesWeight AliasesWeights = 13;
}

message TMetaComponent {
    required string ServiceName = 1;
    required uint32 SearchPriority = 2;
    required bool SearchDisabled = 3;
    required bool IndexDisabled = 4;
    optional bool IndexReplyIgnoring = 5 [default = false];
}

message TMetaService {
    required TService ServiceInfo = 1;
    repeated TMetaComponent Components = 2;
}

message TLinearSearchMap {
    repeated TService Services = 2;
}

message TCluster {
    repeated TMetaService MetaServices = 1;
    optional TLinearSearchMap Service = 2;
    optional TLinearSearchMap IntMeta = 3;
    optional TLinearSearchMap Suggest = 4;
}
