Package org.dbos.apiary.client
Class ApiaryWorkerClient
java.lang.Object
org.dbos.apiary.client.ApiaryWorkerClient
ApiaryWorkerClient provides an interface for invoking Apiary functions from a remote client.
This class is not thread-safe.
-
Constructor Summary
ConstructorsConstructorDescriptionApiaryWorkerClient
(String apiaryWorkerAddress) Create a client for sending synchronous requests to Apiary.ApiaryWorkerClient
(String apiaryWorkerAddress, org.zeromq.ZContext zContext) Create a client for sending asynchronous requests to Apiary. -
Method Summary
Modifier and TypeMethodDescriptionexecuteFunction
(String name, Object... arguments) Invoke a function synchronously and block waiting for the result.int
Get the globally unique clientID of this current client.org.zeromq.ZMQ.Socket
Get a ZMQ socket for sending asynchronous requests.byte[]
serializeExecuteRequest
(String name, String service, Object... arguments) Serialize a function invocation request, used for sending asynchronous requests.
-
Constructor Details
-
ApiaryWorkerClient
Create a client for sending synchronous requests to Apiary.- Parameters:
apiaryWorkerAddress
- the address of an Apiary worker.
-
ApiaryWorkerClient
Create a client for sending asynchronous requests to Apiary.- Parameters:
apiaryWorkerAddress
- the address of an Apiary worker.zContext
- the ZContext to be used for sending requests and receiving replies.
-
-
Method Details
-
getSocket
Get a ZMQ socket for sending asynchronous requests.- Parameters:
address
- the address of an Apiary worker.- Returns:
- a
ZMQ.Socket
object that can be used to send requests.
-
serializeExecuteRequest
Serialize a function invocation request, used for sending asynchronous requests.- Parameters:
name
- the name of the invoked function.service
- the service name of this invocation.arguments
- the arguments of the invoked function.- Returns:
- serialized byte array of the request.
-
executeFunction
public FunctionOutput executeFunction(String name, Object... arguments) throws com.google.protobuf.InvalidProtocolBufferException Invoke a function synchronously and block waiting for the result.- Parameters:
name
- the name of the invoked function.arguments
- the arguments of the invoked function.- Returns:
- the output of the invoked function.
- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
getClientID
public int getClientID()Get the globally unique clientID of this current client.- Returns:
- the unique ID of this client.
-