// Copyright 2023 Greptime Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package greptime.v1.meta;

option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1/meta";

message RequestHeader {
  uint64 protocol_version = 1;
  // member_id is the ID of the sender server.
  uint64 member_id = 3;
  // The role of the sender server.
  Role role = 4;
  // Encoded trace_id & span_id, follow the w3c Trace Context
  // https://www.w3.org/TR/trace-context/#header-name
  map<string, string> tracing_context = 5;
}

enum Role {
  DATANODE = 0;
  FRONTEND = 1;
  FLOWNODE = 2;
}

message ResponseHeader {
  uint64 protocol_version = 1;
  Error error = 3;
}

message Error {
  int32 code = 1;
  string err_msg = 2;
}

message Peer {
  uint64 id = 1;
  string addr = 2;
}

message TimeInterval {
  // The unix timestamp in millis of the start of this period.
  int64 start_timestamp_millis = 1;
  // The unix timestamp in millis of the end of this period.
  int64 end_timestamp_millis = 2;
}

message KeyValue {
  // key is the key in bytes. An empty key is not allowed.
  bytes key = 1;
  // value is the value held by the key, in bytes.
  bytes value = 2;
}

// Procedure identifier
message ProcedureId { bytes key = 1; }
