|
| 1 | +syntax = "proto3"; |
| 2 | + |
| 3 | +import "protosocket/common.proto"; |
| 4 | + |
| 5 | +// This is the protobuf definition for the Momento Cache service. |
| 6 | +// It is available over protosocket-rpc. |
| 7 | +package cache; |
| 8 | + |
| 9 | +// All messages sent to the server by a client must be CacheCommands. |
| 10 | +message CacheCommand { |
| 11 | + // This is the unique identifier used for the command. The server will return this id in the response. |
| 12 | + // As protosocket-rpc does not necessarily respond in-order this is used to correlate responses with requests. |
| 13 | + uint64 message_id = 2; |
| 14 | + // The protosocket-rpc control code. |
| 15 | + uint32 control_code = 3; |
| 16 | + // The protosocket-rpc rpc kind. |
| 17 | + oneof rpc_kind { |
| 18 | + Unary unary = 10; |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +// These are Unary (single request -> single response) commands. |
| 23 | +message Unary { |
| 24 | + oneof command { |
| 25 | + // Authenticate provides the auth token to be used for all future requests on the connection. |
| 26 | + // - It MUST be the first command sent on every cache connection. |
| 27 | + // - It MAY be resent later in the connection to provide a different auth token. |
| 28 | + // - If sent mid-connection, clients SHOULD wait to pipeline further commands until the corresponding response is received. |
| 29 | + // If clients do not wait, it is indeterminate whether the prior or new auth token will be used for those requests. |
| 30 | + AuthenticateCommand auth = 1; |
| 31 | + // Retrieves an item from cache. |
| 32 | + GetCommand get = 2; |
| 33 | + // Set an item in cache. |
| 34 | + SetCommand set = 3; |
| 35 | + // Deletes an item from cache. |
| 36 | + DeleteCommand delete = 4; |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +// All messages sent by the server to a client will be CacheResponses. |
| 41 | +message CacheResponse { |
| 42 | + // This is the message id provided in the corresponding command. |
| 43 | + uint64 message_id = 1; |
| 44 | + // The protosocket-rpc control code. |
| 45 | + uint32 control_code = 2; |
| 46 | + // The specific response. |
| 47 | + oneof kind { |
| 48 | + common.CommandError error = 9; |
| 49 | + AuthenticateResponse auth = 10; |
| 50 | + GetResponse get = 11; |
| 51 | + SetResponse set = 12; |
| 52 | + DeleteResponse delete = 13; |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +message AuthenticateCommand { |
| 57 | + string token = 1; |
| 58 | +} |
| 59 | + |
| 60 | +message AuthenticateResponse {} |
| 61 | + |
| 62 | +message GetCommand { |
| 63 | + string namespace = 1; |
| 64 | + bytes key = 2; |
| 65 | +} |
| 66 | + |
| 67 | +message GetResponse { |
| 68 | + bytes value = 1; |
| 69 | +} |
| 70 | + |
| 71 | +message SetCommand { |
| 72 | + string namespace = 1; |
| 73 | + bytes key = 2; |
| 74 | + bytes value = 3; |
| 75 | + uint64 ttl_milliseconds = 4; |
| 76 | +} |
| 77 | +message SetResponse {} |
| 78 | + |
| 79 | +message DeleteCommand { |
| 80 | + string namespace = 1; |
| 81 | + bytes key = 2; |
| 82 | +} |
| 83 | +message DeleteResponse { |
| 84 | +} |
0 commit comments