syntax = "proto3";

package mesh.v1;

option go_package = "atlassian.com/bitbucket/mesh/rpc/v1";
option java_multiple_files = true;
option java_outer_classname = "StreamProtos";
option java_package = "com.atlassian.bitbucket.mesh.rpc.v1";

/* Represents a chunk of data from a stream */
message RpcStreamChunk {
  bytes data = 1;
  bool closed = 2; //True if this will be the final chunk for this stream type
}

/* A general response fragment (either a chunk of data from a stream, or the result of the command).
 * Many commands return a stream of these fragments to allow incremental streaming of command output
 * to the client */
message RpcStreamFragment {
  oneof fragment_oneof {
    RpcStreamStart start = 1;
    RpcStreamChunk stdout = 2;
    RpcStreamChunk stderr = 3;
    RpcStreamResult result = 4;
  }
}

/* Represents the outcome of a command */
message RpcStreamResult {
  int32 exit_code = 1;
}

/* Represents the beginning of a fragmented stream, providing some context */
message RpcStreamStart {
  bytes command_line = 1;
}
