1*61c4878aSAndroid Build Coastguard Worker// Copyright 2020 The Pigweed Authors 2*61c4878aSAndroid Build Coastguard Worker// 3*61c4878aSAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); you may not 4*61c4878aSAndroid Build Coastguard Worker// use this file except in compliance with the License. You may obtain a copy of 5*61c4878aSAndroid Build Coastguard Worker// the License at 6*61c4878aSAndroid Build Coastguard Worker// 7*61c4878aSAndroid Build Coastguard Worker// https://www.apache.org/licenses/LICENSE-2.0 8*61c4878aSAndroid Build Coastguard Worker// 9*61c4878aSAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 10*61c4878aSAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11*61c4878aSAndroid Build Coastguard Worker// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12*61c4878aSAndroid Build Coastguard Worker// License for the specific language governing permissions and limitations under 13*61c4878aSAndroid Build Coastguard Worker// the License. 14*61c4878aSAndroid Build Coastguard Workersyntax = "proto3"; 15*61c4878aSAndroid Build Coastguard Worker 16*61c4878aSAndroid Build Coastguard Workerpackage pw.rpc.internal; 17*61c4878aSAndroid Build Coastguard Worker 18*61c4878aSAndroid Build Coastguard Workeroption java_package = "dev.pigweed.pw_rpc.internal"; 19*61c4878aSAndroid Build Coastguard Worker 20*61c4878aSAndroid Build Coastguard Workerenum PacketType { 21*61c4878aSAndroid Build Coastguard Worker // To simplify identifying the origin of a packet, client-to-server packets 22*61c4878aSAndroid Build Coastguard Worker // use even numbers and server-to-client packets use odd numbers. 23*61c4878aSAndroid Build Coastguard Worker 24*61c4878aSAndroid Build Coastguard Worker // Client-to-server packets 25*61c4878aSAndroid Build Coastguard Worker 26*61c4878aSAndroid Build Coastguard Worker // The client invokes an RPC. Always the first packet. 27*61c4878aSAndroid Build Coastguard Worker REQUEST = 0; 28*61c4878aSAndroid Build Coastguard Worker 29*61c4878aSAndroid Build Coastguard Worker // A message in a client stream. Always sent after a REQUEST and before a 30*61c4878aSAndroid Build Coastguard Worker // CLIENT_REQUEST_COMPLETION. 31*61c4878aSAndroid Build Coastguard Worker CLIENT_STREAM = 2; 32*61c4878aSAndroid Build Coastguard Worker 33*61c4878aSAndroid Build Coastguard Worker // The client received a packet for an RPC it did not request. 34*61c4878aSAndroid Build Coastguard Worker CLIENT_ERROR = 4; 35*61c4878aSAndroid Build Coastguard Worker 36*61c4878aSAndroid Build Coastguard Worker // Client has requested for call completion. In client streaming and 37*61c4878aSAndroid Build Coastguard Worker // bi-directional streaming RPCs, this also indicates that the client is done 38*61c4878aSAndroid Build Coastguard Worker // with sending requests. 39*61c4878aSAndroid Build Coastguard Worker CLIENT_REQUEST_COMPLETION = 8; 40*61c4878aSAndroid Build Coastguard Worker 41*61c4878aSAndroid Build Coastguard Worker // Server-to-client packets 42*61c4878aSAndroid Build Coastguard Worker 43*61c4878aSAndroid Build Coastguard Worker // The RPC has finished. 44*61c4878aSAndroid Build Coastguard Worker RESPONSE = 1; 45*61c4878aSAndroid Build Coastguard Worker 46*61c4878aSAndroid Build Coastguard Worker // The server was unable to process a request. 47*61c4878aSAndroid Build Coastguard Worker SERVER_ERROR = 5; 48*61c4878aSAndroid Build Coastguard Worker 49*61c4878aSAndroid Build Coastguard Worker // A message in a server stream. 50*61c4878aSAndroid Build Coastguard Worker SERVER_STREAM = 7; 51*61c4878aSAndroid Build Coastguard Worker 52*61c4878aSAndroid Build Coastguard Worker // Reserve field numbers for deprecated PacketTypes. 53*61c4878aSAndroid Build Coastguard Worker reserved 3; // SERVER_STREAM_END (equivalent to RESPONSE now) 54*61c4878aSAndroid Build Coastguard Worker reserved 6; // CANCEL (replaced by CLIENT_ERROR with status CANCELLED) 55*61c4878aSAndroid Build Coastguard Worker} 56*61c4878aSAndroid Build Coastguard Worker 57*61c4878aSAndroid Build Coastguard Workermessage RpcPacket { 58*61c4878aSAndroid Build Coastguard Worker // The type of packet. Determines which other fields are used. 59*61c4878aSAndroid Build Coastguard Worker PacketType type = 1; 60*61c4878aSAndroid Build Coastguard Worker 61*61c4878aSAndroid Build Coastguard Worker // Channel through which the packet is sent. 62*61c4878aSAndroid Build Coastguard Worker uint32 channel_id = 2; 63*61c4878aSAndroid Build Coastguard Worker 64*61c4878aSAndroid Build Coastguard Worker // Hash of the fully-qualified name of the service with which this packet is 65*61c4878aSAndroid Build Coastguard Worker // associated. For RPC packets, this is the service that processes the packet. 66*61c4878aSAndroid Build Coastguard Worker fixed32 service_id = 3; 67*61c4878aSAndroid Build Coastguard Worker 68*61c4878aSAndroid Build Coastguard Worker // Hash of the name of the method which should process this packet. 69*61c4878aSAndroid Build Coastguard Worker fixed32 method_id = 4; 70*61c4878aSAndroid Build Coastguard Worker 71*61c4878aSAndroid Build Coastguard Worker // The packet's payload, which is an encoded protobuf. 72*61c4878aSAndroid Build Coastguard Worker bytes payload = 5; 73*61c4878aSAndroid Build Coastguard Worker 74*61c4878aSAndroid Build Coastguard Worker // Status code for the RPC response or error. 75*61c4878aSAndroid Build Coastguard Worker uint32 status = 6; 76*61c4878aSAndroid Build Coastguard Worker 77*61c4878aSAndroid Build Coastguard Worker // Unique identifier for the call that initiated this RPC. Optionally set by 78*61c4878aSAndroid Build Coastguard Worker // the client in the initial request and sent in all subsequent client 79*61c4878aSAndroid Build Coastguard Worker // packets; echoed by the server. 80*61c4878aSAndroid Build Coastguard Worker uint32 call_id = 7; 81*61c4878aSAndroid Build Coastguard Worker} 82