syntax = "proto3";

package gitaly;

option go_package = "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb";

import "lint.proto";
import "shared.proto";

service RefTransaction {

  rpc VoteTransaction (VoteTransactionRequest) returns (VoteTransactionResponse) {
    option (op_type) = {
      op:          MUTATOR
      scope_level: REPOSITORY
    };
  }

  rpc StopTransaction (StopTransactionRequest) returns (StopTransactionResponse) {
    option (op_type) = {
      op:          MUTATOR
      scope_level: REPOSITORY
    };
  }

}

message VoteTransactionRequest {
  Repository repository = 1[(target_repository)=true];
  // ID of the transaction we're processing
  uint64 transaction_id = 2;
  // Name of the Gitaly node that's voting on a transaction.
  string node = 3;
  // SHA1 of the references that are to be updated
  bytes reference_updates_hash = 4;
}

message VoteTransactionResponse {
  // The outcome of the given transaction telling the client whether the
  // transaction should be committed or rolled back.
  enum TransactionState {
    COMMIT = 0;
    ABORT = 1;
    STOP = 2;
  }

  TransactionState state = 1;
}

message StopTransactionRequest {
  Repository repository = 1[(target_repository)=true];
  // ID of the transaction we're processing
  uint64 transaction_id = 2;
}

message StopTransactionResponse {}
