/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * license agreements; and to You under the Apache License, version 2.0:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * This file is part of the Apache Pekko project, which was derived from Akka.
 */

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

syntax = "proto2";

option java_package = "org.apache.pekko.persistence.serialization";
option optimize_for = SPEED;

message PersistentMessage {
  optional PersistentPayload payload = 1;
  optional int64 sequenceNr = 2;
  optional string persistenceId = 3;
  optional bool deleted = 4; // not used in new records from Akka 2.4
  // optional int32 redeliveries = 6; // Removed in Akka 2.4
  // repeated string confirms = 7; // Removed in Akka 2.4
  // optional bool confirmable = 8;  // Removed in Akka 2.4
  // optional DeliveredMessage confirmMessage = 9; // Removed in Akka 2.4
  // optional string confirmTarget = 10; // Removed in Akka 2.4
  optional string sender = 11; // not stored in journal, needed for remote serialization 
  optional string manifest = 12;
  optional string writerUuid = 13;
  optional sint64 timestamp = 14;
  optional PersistentPayload metadata = 15;
}

message PersistentPayload {
  required int32 serializerId = 1;
  required bytes payload = 2;
  optional bytes payloadManifest = 3;
}

message AtomicWrite {
  repeated PersistentMessage payload = 1;
}

message AtLeastOnceDeliverySnapshot {
  message UnconfirmedDelivery {
    required int64 deliveryId = 1;
    required string destination = 2;
    required PersistentPayload payload = 3;
  }
  
  required int64 currentDeliveryId = 1;
  repeated UnconfirmedDelivery unconfirmedDeliveries = 2;
}

message PersistentStateChangeEvent {
  required string stateIdentifier = 1;
  optional string timeout = 2; //not used in new records from Akka 2.4.5
  optional int64 timeoutNanos = 3;
}

message PersistentFSMSnapshot {
  required string stateIdentifier = 1;
  required PersistentPayload data = 2;
  optional int64 timeoutNanos = 3;
}
