aboutsummaryrefslogtreecommitdiff
path: root/pw_rpc/pw_rpc_protos/packet.proto
blob: 459ac94c66f6ddca019ec51c9ec3421e29a0b76b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2020 The Pigweed 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
//
//     https://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 pw.rpc.internal;

option java_package = "dev.pigweed.pw.rpc.internal";

enum PacketType {
  // To simplify identifying the origin of a packet, client-to-server packets
  // use even numbers and server-to-client packets use odd numbers.

  // Client-to-server packets

  // A request from a client for a service method.
  REQUEST = 0;

  // A client stream has completed.
  CLIENT_STREAM_END = 2;

  // The client received a packet for an RPC it did not request.
  CLIENT_ERROR = 4;

  // The client requests cancellation of an ongoing server stream.
  CANCEL_SERVER_STREAM = 6;

  // Server-to-client packets

  // A response from a server for a service method.
  RESPONSE = 1;

  // A server streaming or bidirectional RPC has completed.
  SERVER_STREAM_END = 3;

  // The server was unable to process a request.
  SERVER_ERROR = 5;
}

message RpcPacket {
  // The type of packet. Determines which other fields are used.
  PacketType type = 1;

  // Channel through which the packet is sent.
  uint32 channel_id = 2;

  // Hash of the fully-qualified name of the service with which this packet is
  // associated. For RPC packets, this is the service that processes the packet.
  fixed32 service_id = 3;

  // Hash of the name of the method which should process this packet.
  fixed32 method_id = 4;

  // The packet's payload, which is an encoded protobuf.
  bytes payload = 5;

  // Status code for the RPC response or error.
  uint32 status = 6;
}