Search in sources :

Example 1 with GetResponse

use of com.scalar.db.rpc.TransactionResponse.GetResponse in project scalardb by scalar-labs.

the class GrpcTransactionOnBidirectionalStream method get.

public Optional<Result> get(Get get) throws CrudException {
    throwIfTransactionFinished();
    ResponseOrError responseOrError = sendRequest(TransactionRequest.newBuilder().setGetRequest(GetRequest.newBuilder().setGet(ProtoUtils.toGet(get))).build());
    throwIfErrorForCrud(responseOrError);
    GetResponse getResponse = responseOrError.getResponse().getGetResponse();
    if (getResponse.hasResult()) {
        TableMetadata tableMetadata = getTableMetadata(get);
        return Optional.of(ProtoUtils.toResult(getResponse.getResult(), tableMetadata));
    }
    return Optional.empty();
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata) GetResponse(com.scalar.db.rpc.TransactionResponse.GetResponse)

Aggregations

TableMetadata (com.scalar.db.api.TableMetadata)1 GetResponse (com.scalar.db.rpc.TransactionResponse.GetResponse)1