/*
 * Copyright (C) 2017-2021 Lightbend Inc. <https://www.lightbend.com>
 */

syntax = "proto2";

option java_package = "akka.persistence.typed.serialization";
option optimize_for = SPEED;
import "ContainerFormats.proto";

message Counter {
    required bytes value = 1;
}

message CounterUpdate {
    required bytes delta = 1;
}

message ORSet {
  required string originDc = 1;
  required VersionVector vvector = 2;
  repeated VersionVector dots = 3; 
  repeated string stringElements = 4;
  repeated sint32 intElements = 5 [packed=true];
  repeated sint64 longElements = 6 [packed=true];
  repeated Payload otherElements = 7;
}

message ORSetDeltaGroup {
  message Entry {
    required ORSetDeltaOp operation = 1;
    required ORSet underlying = 2;
  }
  
  repeated Entry entries = 1;
}

enum ORSetDeltaOp {
  Add = 0;
  Remove = 1;
  Full = 2;
}

message VersionVector {
  message Entry {
    required string key = 1;
    required int64 version = 2;
  }
  repeated Entry entries = 1;
}

message ReplicatedEventMetadata {
  required string originReplica = 1;
  required int64 originSequenceNr = 2;
  required VersionVector versionVector = 3;
  required bool concurrent = 4;
}

message ReplicatedSnapshotMetadata {
  message Seen {
    required string replicaId = 1;
    required int64 sequenceNr = 2;
  }
  required VersionVector version = 1;
  repeated Seen seenPerReplica = 2;
}

message ReplicatedPublishedEventMetaData {
  optional string replicaId = 1;
  optional VersionVector versionVector = 2;
}

message PublishedEvent {
  optional string persistenceId = 1;
  optional int64 sequenceNr = 2;
  optional Payload payload = 3;
  optional int64 timestamp = 4;
  optional ReplicatedPublishedEventMetaData metadata = 5;
}