// 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.frontend;

option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1/frontend";
option java_outer_classname = "Server";
option java_package = "io.greptime.v1.frontend";

service Frontend {
  // List all running processes on frontend.
  rpc ListProcess(ListProcessRequest) returns (ListProcessResponse);
  // Kill a running process on frontend.
  rpc KillProcess(KillProcessRequest) returns (KillProcessResponse);
}

message ListProcessRequest {
  string catalog = 1;
}

message ListProcessResponse {
  repeated ProcessInfo processes = 1;
}

message KillProcessRequest {
  // Frontend server address of process.
  string server_addr = 1;
  // Catalog of process to kill.
  string catalog = 2;
  // ID of process to kill.
  uint32 process_id = 3;
}

message KillProcessResponse {
  // Whether targeting process is successfully killed
  bool success = 1;
}

message ProcessInfo {
  // ID.
  uint32 id = 1;
  // Catalog of process.
  string catalog = 2;
  // Involved schemas.
  repeated string schemas = 3;
  // Query string.
  string query = 4;
  // Start time.
  int64 start_timestamp = 5;
  // Client info.
  string client = 6;
  // Frontend info of process.
  string frontend = 7;
}
