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

syntax = "proto2";

package akka.cluster.ddata;

option java_package = "akka.cluster.ddata.protobuf.msg";
option optimize_for = SPEED;
import "ReplicatorMessages.proto";

message GSet {
  repeated string stringElements = 1;
  repeated sint32 intElements = 2 [packed=true];
  repeated sint64 longElements = 3 [packed=true];
  repeated OtherMessage otherElements = 4;
  repeated string actorRefElements = 5; // added in Akka 2.5.14
}

message ORSet {
  required VersionVector vvector = 1;
  repeated VersionVector dots = 2; 
  repeated string stringElements = 3;
  repeated sint32 intElements = 4 [packed=true];
  repeated sint64 longElements = 5 [packed=true];
  repeated OtherMessage otherElements = 6;
  repeated string actorRefElements = 7; // added in Akka 2.5.14
}

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 Flag {
  required bool enabled = 1;
}

message LWWRegister {
  required sint64 timestamp = 1;
  required UniqueAddress node = 2;
  required OtherMessage state = 3;
}

message GCounter {
  message Entry {
    required UniqueAddress node = 1;
    required bytes value = 2;
  }
  
  repeated Entry entries = 1; 
}

message PNCounter {
  required GCounter increments = 1;
  required GCounter decrements = 2;
}

message ORMap {
  message Entry {
    optional string stringKey = 1;
    required OtherMessage value = 2;
    optional sint32 intKey = 3;
    optional sint64 longKey = 4;
    optional OtherMessage otherKey = 5;
  }
  
  required ORSet keys = 1;
  repeated Entry entries = 2;
}

message ORMapDeltaGroup {
  message MapEntry {
    optional string stringKey = 1;
    optional OtherMessage value = 2;
    optional sint32 intKey = 3;
    optional sint64 longKey = 4;
    optional OtherMessage otherKey = 5;
  }
  message Entry {
    required ORMapDeltaOp operation = 1;
    required ORSet underlying = 2;
    required sint32 zeroTag = 3;
    repeated MapEntry entryData = 4;
  }

  repeated Entry entries = 1;
}

enum ORMapDeltaOp {
  ORMapPut = 0;
  ORMapRemove = 1;
  ORMapRemoveKey = 2;
  ORMapUpdate = 3;
}

message LWWMap {
  message Entry {
    optional string stringKey = 1;
    required LWWRegister value = 2;
    optional sint32 intKey = 3;
    optional sint64 longKey = 4;
    optional OtherMessage otherKey = 5;
  }
  
  required ORSet keys = 1;
  repeated Entry entries = 2;
}

message PNCounterMap {
  message Entry {
    optional string stringKey = 1;
    required PNCounter value = 2;
    optional sint32 intKey = 3;
    optional sint64 longKey = 4;
    optional OtherMessage otherKey = 5;
  }
  
  required ORSet keys = 1;
  repeated Entry entries = 2;
}

message ORMultiMap {
   message Entry {
     optional string stringKey = 1;
     required ORSet value = 2;
     optional sint32 intKey = 3;
     optional sint64 longKey = 4;
     optional OtherMessage otherKey = 5;
   }

   required ORSet keys = 1;
   repeated Entry entries = 2;
   optional bool withValueDeltas = 3;
 }



