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