//
// Copyright 2022 The Project Oak Authors
//
// 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 micro_rpc;

option java_multiple_files = true;
option java_package = "com.google.micro_rpc";

// A wrapper message representing a request over a transport.
message RequestWrapper {
  // The id of the method to invoke. This is usually specified via the IDL that
  // drives the code generation. In other contexts (e.g. gRPC), IDLs may use the
  // method name as part of the serialization, but here we prefer an opaque
  // numeric identifier for both conciseness and stability across renames.
  uint32 method_id = 1;
  // The bytes of the serialized request.
  bytes body = 2;
}

// A message representing an error status code with associated message.
//
// Similar to
// https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto.
message Status {
  // The status code, which should be an enum value of
  // https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto.
  int32 code = 1;

  // A developer-facing error message, which should be in English.
  string message = 2;
}

// A wrapper message representing a response over a transport.
message ResponseWrapper {
  oneof response {
    // A status / error message, in case of failure.
    Status error = 1;
    // The bytes of the serialized response, if successful.
    bytes body = 2;
  }
}
