// Copyright 2016 Google Inc.
//
// 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.
//
// Author: cheesy@google.com (Steve Hill)

syntax = "proto3";

package net_instaweb;

option cc_generic_services = false;

service CentralControllerRpcService {
  // RPC bridge for ScheduleRewriteController.
  // Send a ScheduleRewriteRequest with only a key, then wait for a
  // ScheduleRewriteResponse letting you know if it's OK to proceed. If true,
  // send another Request with only a status to indicate success/failure.
  // See schedule_rewrite_rpc_handler.h and schedule_rewrite_controller.h
  rpc ScheduleRewrite(stream ScheduleRewriteRequest)
      returns (stream ScheduleRewriteResponse) {
  }

  // RPC bridge for ExpensiveOperationController.
  // Send a ScheduleExpensiveOperationRequest, then wait for a
  // ScheduleRewriteResponse letting you know if it's OK to proceed. If true,
  // send another Request when you are done. There is no payload in the request
  // since they are just used for synchronization.
  // See expensive_operation_rpc_handler.h and expensive_operation_controller.h
  rpc ScheduleExpensiveOperation(stream ScheduleExpensiveOperationRequest)
      returns (stream ScheduleExpensiveOperationResponse) {
  }
}

message ScheduleRewriteRequest {
  enum RewriteStatus {
    PENDING = 0;
    SUCCESS = 1;
    FAILED = 2;
  };

  string key = 1;
  RewriteStatus status = 2;
}

message ScheduleRewriteResponse {
  bool ok_to_proceed = 1;
}

message ScheduleExpensiveOperationRequest {
}

message ScheduleExpensiveOperationResponse {
  bool ok_to_proceed = 1;
}
