public class TxGrpcCommunicator extends Object implements AutoCloseable
GrpcGrakn.TxRequests and receiving a
stream of GrpcGrakn.TxResponses.
A request is sent with the #send(TxRequest)} method, and you can block for a response with the
receive() method.
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub) {
tx.send(openMessage);
TxResponse doneMessage = tx.receive().ok();
tx.send(commitMessage);
StatusRuntimeException validationError = tx.receive.error();
}
| Modifier and Type | Class and Description |
|---|---|
static class |
TxGrpcCommunicator.Response
A response from the gRPC server, that may be a successful response
#ok(TxResponse), an error
{@link #error(StatusRuntimeException)} or a "completed" message TxGrpcCommunicator.Response.completed(). |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static TxGrpcCommunicator |
create(GraknGrpc.GraknStub stub) |
boolean |
isClosed() |
TxGrpcCommunicator.Response |
receive()
Block until a response is returned.
|
void |
send(GrpcGrakn.TxRequest request)
Send a request and return immediately.
|
public static TxGrpcCommunicator create(GraknGrpc.GraknStub stub)
public void send(GrpcGrakn.TxRequest request)
public TxGrpcCommunicator.Response receive() throws InterruptedException
InterruptedExceptionpublic void close()
close in interface AutoCloseablepublic boolean isClosed()
Copyright © 2018 Grakn Labs Ltd. All rights reserved.