/*
 * 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.stream";
option optimize_for = SPEED;

/*************************************************
  StreamRefs (SourceRef / SinkRef) related formats
**************************************************/

message SinkRef {
    required ActorRef targetRef = 1;
}

message SourceRef {
    required ActorRef originRef = 1;
}

message ActorRef {
    required string path = 1;
}

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

// stream refs protocol

message OnSubscribeHandshake {
    required ActorRef targetRef = 1;
}
message CumulativeDemand {
    required int64 seqNr = 1;
}

message SequencedOnNext {
    required int64 seqNr = 1;
    required Payload payload = 2;
}

message RemoteStreamFailure {
    optional bytes cause = 1;
}

message RemoteStreamCompleted {
    required int64 seqNr = 1;
}
