// SPDX-FileCopyrightText: 2020 The Magma Authors.
// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
//
// SPDX-License-Identifier: BSD-3-Clause

syntax = "proto3";

package magma.orc8r;

import "google/protobuf/any.proto";

option go_package = "magma/orc8r/lib/go/protos";

// Streamer provides a pipeline for the cloud to push the updates to the
// gateway as and when the update happens.
//
// The Streamer interface defines the semantics and consistency guarantees
// between the cloud and the gateway while abstracting the details of how
// it's implemented in the cloud and what the gateway does with the updates.
//
// - The gateways call the GetUpdates() streaming API with a StreamRequest
//   indicating the stream name and the offset to continue streaming from.
// - The cloud sends a stream of DataUpdateBatch containing a batch of updates.
// - If resync is true, then the gateway can cleanup all its data and add
//   all the keys (the batch is guaranteed to contain only unique keys).
// - If resync is false, then the gateway can update the keys, or add new
//   ones if the key is not already present.
// - Key deletions are not yet supported (#15109350)
service Streamer {
  // GetUpdates streams config updates from the cloud.
  // The RPC call would be kept open to push new updates as they happen.
  rpc GetUpdates (StreamRequest) returns (stream DataUpdateBatch) {}
}

message StreamRequest {
  string gatewayId = 1;
  // stream_name to attach to.
  // E.g., subscriberdb, config, etc.
  string stream_name = 2;
  // extra_args contain any extra data to send up with the stream request.
  // This value will be different per stream provider.
  google.protobuf.Any extra_args = 3;
}

message DataUpdateBatch {
  // updates to config values
  repeated DataUpdate updates = 1;
  // resync is true iff the updates would be a snapshot of all the contents
  // in the cloud.
  bool resync = 2;
}

message DataUpdate {
  // key is the unique key for each item
  string key = 1;
  // value can be file contents, protobuf serialized message, etc.
  // For key deletions, the value field would be absent.
  bytes value = 2;
}
