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