Search in sources :

Example 1 with StartRequest

use of com.scalar.db.rpc.TwoPhaseCommitTransactionRequest.StartRequest in project scalardb by scalar-labs.

the class GrpcTwoPhaseCommitTransactionOnBidirectionalStream method startTransaction.

public String startTransaction(@Nullable String transactionId) throws TransactionException {
    throwIfTransactionFinished();
    StartRequest request;
    if (transactionId == null) {
        request = StartRequest.getDefaultInstance();
    } else {
        request = StartRequest.newBuilder().setTransactionId(transactionId).build();
    }
    ResponseOrError responseOrError = sendRequest(TwoPhaseCommitTransactionRequest.newBuilder().setStartRequest(request).build());
    throwIfErrorForStartOrJoin(responseOrError, true);
    return responseOrError.getResponse().getStartResponse().getTransactionId();
}
Also used : StartRequest(com.scalar.db.rpc.TwoPhaseCommitTransactionRequest.StartRequest)

Aggregations

StartRequest (com.scalar.db.rpc.TwoPhaseCommitTransactionRequest.StartRequest)1