import "mapreduce/yt/interface/protos/extension.proto";

package NBalancerYt.NProto;

message TProcessingTree {
    message TPayload {
        oneof PayloadType {
            string Value = 1;
            TProcessingTree Tree = 2;
        }
    }
    optional string ModuleName = 1;
    repeated TPayload Payload = 2;
}

message THamsterLog {
    optional string Url = 1 [(NYT.column_name) = "url"];
    optional string Duration = 2 [(NYT.column_name) = "duration"];
    optional string Referrer = 3 [(NYT.column_name) = "referrer"];
    optional string HostHeader = 4 [(NYT.column_name) = "host_header"];
    optional string Source = 5 [(NYT.column_name) = "source"];
    optional string SourceUri = 6 [(NYT.column_name) = "source_uri"];
    optional string ProcessingTree = 7 [(NYT.column_name) = "processing_tree"];
    optional string StartTime = 8 [(NYT.column_name) = "start_time"];
}

message TProdLog {
    optional string Url = 1 [(NYT.column_name) = "query"];
    optional string Duration = 2 [(NYT.column_name) = "work_time"];
    optional string Referrer = 3 [(NYT.column_name) = "referer"];
    optional string HostHeader = 4 [(NYT.column_name) = "host"];
    optional string Source = 5 [(NYT.column_name) = "ip_port"];
    optional string SourceUri = 6 [(NYT.column_name) = "source_uri"];
    optional string ProcessingTree = 7 [(NYT.column_name) = "workflow"];
    optional string StartTime = 8 [(NYT.column_name) = "timestamp"];
}

message TLog {
    optional int64 Duration = 1 [(NYT.column_name) = "duration"]; // microseconds
    optional TProcessingTree ProcessingTree = 2 [(NYT.column_name) = "processing_tree"];
    optional int64 StartTime = 3 [(NYT.column_name) = "start_time"]; // microseconds
    optional string ReqId = 4 [(NYT.column_name) = "req-id"];
}

message TResolvedLog {
    optional int64 Duration = 1 [(NYT.column_name) = "duration"]; // microseconds
    optional int64 StartTime = 2 [(NYT.column_name) = "start_time"]; // microseconds
    optional string ReqId = 3 [(NYT.column_name) = "req-id"];

    optional string Destination = 4 [(NYT.column_name) = "destination"];
    optional string Error = 5 [(NYT.column_name) = "error"]; // error
    optional string ErrorType = 6 [(NYT.column_name) = "error-type"]; // error type (client/server error)
    optional string ResponseCode = 7 [(NYT.column_name) = "response-code"];
}

message TBackendStat {
    message TStat {
        optional int64 Requests = 1;
        optional double MeanDuration = 2;
    }
    message TStatDict {
        map<string, TStat> Reduced = 1;
    }
    optional string Destination = 1 [(NYT.column_name) = "dest"];
    optional TStatDict ByError = 2 [(NYT.column_name) = "by-error"];
    optional TStatDict ByErrorType = 3 [(NYT.column_name) = "by-error-type"];
    optional TStatDict ByResponseCode = 4 [(NYT.column_name) = "by-code"];
    optional TStat Stat = 5 [(NYT.column_name) = "stat"];
}

message TBackendStatList {
    repeated TBackendStat Objects = 1;
}
