blob: 459ac94c66f6ddca019ec51c9ec3421e29a0b76b [file] [log] [blame]
Alexei Frolov5d6d3922020-05-08 13:57:02 -07001// 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
Wyatt Heplerba43a3c2020-08-13 12:45:25 -070018option java_package = "dev.pigweed.pw.rpc.internal";
19
Wyatt Hepleraf835682020-06-17 11:42:53 -070020enum PacketType {
Wyatt Hepler0f262352020-07-29 09:51:27 -070021 // To simplify identifying the origin of a packet, client-to-server packets
22 // use even numbers and server-to-client packets use odd numbers.
Wyatt Hepleraf835682020-06-17 11:42:53 -070023
Wyatt Hepler0f262352020-07-29 09:51:27 -070024 // Client-to-server packets
Wyatt Hepler712d3672020-07-13 15:52:11 -070025
Wyatt Heplerba43a3c2020-08-13 12:45:25 -070026 // A request from a client for a service method.
Wyatt Hepler0f262352020-07-29 09:51:27 -070027 REQUEST = 0;
Wyatt Hepler712d3672020-07-13 15:52:11 -070028
Wyatt Hepler0f262352020-07-29 09:51:27 -070029 // A client stream has completed.
30 CLIENT_STREAM_END = 2;
31
32 // The client received a packet for an RPC it did not request.
33 CLIENT_ERROR = 4;
34
35 // The client requests cancellation of an ongoing server stream.
36 CANCEL_SERVER_STREAM = 6;
37
38 // Server-to-client packets
39
40 // A response from a server for a service method.
41 RESPONSE = 1;
42
43 // A server streaming or bidirectional RPC has completed.
44 SERVER_STREAM_END = 3;
45
46 // The server was unable to process a request.
47 SERVER_ERROR = 5;
Wyatt Hepleraf835682020-06-17 11:42:53 -070048}
Alexei Frolov5d6d3922020-05-08 13:57:02 -070049
50message RpcPacket {
Wyatt Heplerba43a3c2020-08-13 12:45:25 -070051 // The type of packet. Determines which other fields are used.
Alexei Frolov5d6d3922020-05-08 13:57:02 -070052 PacketType type = 1;
53
Wyatt Heplerba43a3c2020-08-13 12:45:25 -070054 // Channel through which the packet is sent.
Alexei Frolov5d6d3922020-05-08 13:57:02 -070055 uint32 channel_id = 2;
56
Wyatt Hepler712d3672020-07-13 15:52:11 -070057 // Hash of the fully-qualified name of the service with which this packet is
Alexei Frolov5d6d3922020-05-08 13:57:02 -070058 // associated. For RPC packets, this is the service that processes the packet.
Wyatt Hepler712d3672020-07-13 15:52:11 -070059 fixed32 service_id = 3;
Alexei Frolov5d6d3922020-05-08 13:57:02 -070060
Wyatt Hepler712d3672020-07-13 15:52:11 -070061 // Hash of the name of the method which should process this packet.
62 fixed32 method_id = 4;
Alexei Frolov5d6d3922020-05-08 13:57:02 -070063
Wyatt Hepler712d3672020-07-13 15:52:11 -070064 // The packet's payload, which is an encoded protobuf.
Alexei Frolov5d6d3922020-05-08 13:57:02 -070065 bytes payload = 5;
Alexei Frolov00890942020-05-19 10:45:08 -070066
Wyatt Hepler712d3672020-07-13 15:52:11 -070067 // Status code for the RPC response or error.
Alexei Frolov00890942020-05-19 10:45:08 -070068 uint32 status = 6;
Wyatt Hepleraf835682020-06-17 11:42:53 -070069}