Class ApiaryWorkerClient

java.lang.Object
org.dbos.apiary.client.ApiaryWorkerClient

public class ApiaryWorkerClient extends Object
ApiaryWorkerClient provides an interface for invoking Apiary functions from a remote client. This class is not thread-safe.
  • Constructor Details

    • ApiaryWorkerClient

      public ApiaryWorkerClient(String apiaryWorkerAddress)
      Create a client for sending synchronous requests to Apiary.
      Parameters:
      apiaryWorkerAddress - the address of an Apiary worker.
    • ApiaryWorkerClient

      public ApiaryWorkerClient(String apiaryWorkerAddress, org.zeromq.ZContext zContext)
      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

      public org.zeromq.ZMQ.Socket getSocket(String address)
      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

      public byte[] serializeExecuteRequest(String name, String service, Object... arguments)
      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.