/*
 * 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.cluster.pubsub.protobuf.msg";
option optimize_for = SPEED;

message Status {
  message Version {
    required Address address = 1;
    required int64 timestamp = 2;
  }
  repeated Version versions = 1;
  optional bool replyToStatus = 2;
}

message Delta {
  message Entry {
    required string key = 1;
    required int64 version = 2;
    optional string ref = 3; 
  }
  message Bucket {
    required Address owner = 1;
    required int64 version = 2;
    repeated Entry content = 3;
  }
  repeated Bucket buckets = 1;
}

/**
 * Defines a remote address.
 */
message Address {
  required string system = 1;
  required string hostname = 2;
  required uint32 port = 3;
  optional string protocol = 4;
}

/**
 * Send normally local, but it is also used by the ClusterClient.
 */
message Send {
  required string path = 1;
  required bool localAffinity = 2;
  required Payload payload = 3; 
}

/**
 * SendToAll normally local, but it is also used by the ClusterClient.
 */
message SendToAll {
  required string path = 1;
  required bool allButSelf = 2;
  required Payload payload = 3; 
}

/**
 * Publish normally local, but it is also used by the ClusterClient.
 */
message Publish {
  required string topic = 1;
  required Payload payload = 3; 
}

/**
 * Send a message to only one subscriber of a group.
 */
message SendToOneSubscriber {
  required Payload payload = 1;
}

message Payload {
  required bytes enclosedMessage = 1;
  required int32 serializerId = 2;
  optional bytes messageManifest = 4;
}
