// Copyright 2019 Google LLC
//
// 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
//
//     https://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.

// Microservice wrapping Quickstore
syntax = "proto2";

package mako.internal.quickstore_microservice;

import "proto/quickstore/quickstore.proto";
import "spec/proto/mako.proto";

service Quickstore {
  // Stores the inputs into Mako using Quickstore and returns the generated
  // output.
  rpc Store(StoreInput) returns (StoreOutput) {}
  // Shuts down the Quickstore microservice.
  rpc ShutdownMicroservice(ShutdownInput) returns (ShutdownOutput) {}
}

// TODO(b/134582028) Use this proto as input to the internal Quickstore library
// instead of a multitude of std::vectors.
message StoreInput {
  // REQUIRED
  // Specifies the Mako benchmark to which the data is saved.
  optional mako.quickstore.QuickstoreInput quickstore_input = 1;
  // The SamplePoints holding the data for this test run.
  repeated mako.SamplePoint sample_points = 2;
  // The SampleErrors holding any errors collected during this test run.
  repeated mako.SampleError sample_errors = 3;
  // Additional run aggregates that should be stored in Mako.
  repeated mako.KeyedValue run_aggregates = 4;
  // Additional metric aggregates that should be stored in Mako.
  // All aggregate_value_types must be one of:
  //   * "min"
  //   * "max"
  //   * "mean"
  //   * "median"
  //   * "standard_deviation"
  //   * "median_absolute_deviation"
  //   * "count"
  //   * a percentile (for instance, "p98000").
  // A supplied percentile must correspond to the percentiles set in the
  // benchmark.
  // If any percentiles are provided, the automatically calculated percentiles
  // will be cleared to 0.
  // If any aggregate_value_types are set for a value_key, it will overwrite the
  // entire MetricAggregate for that value_key. Otherwise, metric aggregates
  // will be calculated  automatically based on the data in sample_points.
  repeated string aggregate_value_keys = 5;
  repeated string aggregate_value_types = 6;
  repeated double aggregate_value_values = 7;
}

message StoreOutput {
  // REQUIRED
  // The output generated as a result of using Quickstore.
  // Errors are specified by quickstore_output.status, with more details in
  // quickstore_output.summary_output.
  optional mako.quickstore.QuickstoreOutput quickstore_output = 1;
}

// Empty but unique messages used to allow any future modifications to be
// trivially backwards-compatible.
message ShutdownInput {}
message ShutdownOutput {}
