Wei-Yu Chen | ad55cb8 | 2022-02-15 20:07:01 +0800 | [diff] [blame] | 1 | // SPDX-FileCopyrightText: 2020 The Magma Authors. |
| 2 | // SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org> |
| 3 | // |
| 4 | // SPDX-License-Identifier: BSD-3-Clause |
| 5 | |
| 6 | syntax = "proto3"; |
| 7 | |
| 8 | package magma.orc8r; |
| 9 | |
| 10 | import "google/protobuf/any.proto"; |
| 11 | |
| 12 | option go_package = "magma/orc8r/lib/go/protos"; |
| 13 | |
| 14 | // Streamer provides a pipeline for the cloud to push the updates to the |
| 15 | // gateway as and when the update happens. |
| 16 | // |
| 17 | // The Streamer interface defines the semantics and consistency guarantees |
| 18 | // between the cloud and the gateway while abstracting the details of how |
| 19 | // it's implemented in the cloud and what the gateway does with the updates. |
| 20 | // |
| 21 | // - The gateways call the GetUpdates() streaming API with a StreamRequest |
| 22 | // indicating the stream name and the offset to continue streaming from. |
| 23 | // - The cloud sends a stream of DataUpdateBatch containing a batch of updates. |
| 24 | // - If resync is true, then the gateway can cleanup all its data and add |
| 25 | // all the keys (the batch is guaranteed to contain only unique keys). |
| 26 | // - If resync is false, then the gateway can update the keys, or add new |
| 27 | // ones if the key is not already present. |
| 28 | // - Key deletions are not yet supported (#15109350) |
| 29 | service Streamer { |
| 30 | // GetUpdates streams config updates from the cloud. |
| 31 | // The RPC call would be kept open to push new updates as they happen. |
| 32 | rpc GetUpdates (StreamRequest) returns (stream DataUpdateBatch) {} |
| 33 | } |
| 34 | |
| 35 | message StreamRequest { |
| 36 | string gatewayId = 1; |
| 37 | // stream_name to attach to. |
| 38 | // E.g., subscriberdb, config, etc. |
| 39 | string stream_name = 2; |
| 40 | // extra_args contain any extra data to send up with the stream request. |
| 41 | // This value will be different per stream provider. |
| 42 | google.protobuf.Any extra_args = 3; |
| 43 | } |
| 44 | |
| 45 | message DataUpdateBatch { |
| 46 | // updates to config values |
| 47 | repeated DataUpdate updates = 1; |
| 48 | // resync is true iff the updates would be a snapshot of all the contents |
| 49 | // in the cloud. |
| 50 | bool resync = 2; |
| 51 | } |
| 52 | |
| 53 | message DataUpdate { |
| 54 | // key is the unique key for each item |
| 55 | string key = 1; |
| 56 | // value can be file contents, protobuf serialized message, etc. |
| 57 | // For key deletions, the value field would be absent. |
| 58 | bytes value = 2; |
| 59 | } |