public class API extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
API.FatalError |
static class |
API.ForwardAsyncException |
static class |
API.ForwardSyncException |
static class |
API.InvalidInputException |
static class |
API.MessageDecodingException |
static class |
API.Response |
static class |
API.ReturnAsyncException |
static class |
API.ReturnSyncException |
static class |
API.TerminateException |
static class |
API.TransId |
| Modifier and Type | Field and Description |
|---|---|
static int |
ASYNC |
static PrintStream |
err |
static PrintStream |
out |
static int |
SYNC |
static byte[] |
TransIdNull |
| Constructor and Description |
|---|
API(int thread_index) |
| Modifier and Type | Method and Description |
|---|---|
void |
forward_(Integer request_type,
String name,
byte[] request_info,
byte[] request,
Integer timeout,
Byte priority,
byte[] trans_id,
OtpErlangPid pid)
Forward a message to another service
subscribed that matches the destination service
name. |
void |
forward_async(String name,
byte[] request_info,
byte[] request,
Integer timeout,
Byte priority,
byte[] trans_id,
OtpErlangPid pid)
Asynchronously forward a message to another service
subscribed that matches the destination service
name. |
void |
forward_sync(String name,
byte[] request_info,
byte[] request,
Integer timeout,
Byte priority,
byte[] trans_id,
OtpErlangPid pid)
Synchronously forward a message to another service
subscribed that matches the destination service
name. |
static byte[] |
info_key_value_new(Map<String,List<String>> pairs)
Encode service response info key/value data
|
static byte[] |
info_key_value_new(Map<String,List<String>> pairs,
boolean response)
Encode service response info key/value data
|
static HashMap<String,ArrayList<String>> |
info_key_value_parse(byte[] info)
Decode service request info key/value data
|
ArrayList<API.TransId> |
mcast_async(String name,
byte[] request)
Asynchronous point-multicast communication to services
subscribed that matches the destination service
name. |
ArrayList<API.TransId> |
mcast_async(String name,
byte[] request_info,
byte[] request,
Integer timeout,
Byte priority)
Asynchronous point-multicast communication to services
subscribed that matches the destination service
name. |
boolean |
poll()
Blocks to process incoming CloudI service requests
|
boolean |
poll(int timeout)
Blocks to process incoming CloudI service requests
|
String |
prefix() |
int |
process_count_max() |
int |
process_count_min() |
int |
process_count() |
int |
process_index() |
API.Response |
recv_async()
Asynchronously receive a response.
|
API.Response |
recv_async(boolean consume)
Asynchronously receive a response.
|
API.Response |
recv_async(byte[] trans_id)
Asynchronously receive a response.
|
API.Response |
recv_async(byte[] trans_id,
boolean consume)
Asynchronously receive a response.
|
API.Response |
recv_async(Integer timeout)
Asynchronously receive a response.
|
API.Response |
recv_async(Integer timeout,
boolean consume)
Asynchronously receive a response.
|
API.Response |
recv_async(Integer timeout,
byte[] trans_id)
Asynchronously receive a response.
|
API.Response |
recv_async(Integer timeout,
byte[] trans_id,
boolean consume)
Asynchronously receive a response.
|
void |
return_(Integer request_type,
String name,
String pattern,
byte[] response_info,
byte[] response,
Integer timeout,
byte[] trans_id,
OtpErlangPid pid)
Returns a response from a service request.
|
void |
return_async(String name,
String pattern,
byte[] response_info,
byte[] response,
Integer timeout,
byte[] trans_id,
OtpErlangPid pid)
Asynchronously returns a response from a service request.
|
void |
return_sync(String name,
String pattern,
byte[] response_info,
byte[] response,
Integer timeout,
byte[] trans_id,
OtpErlangPid pid)
Synchronously returns a response from a service request.
|
API.TransId |
send_async(String name,
byte[] request)
Asynchronous point-to-point communication to a service
subscribed that matches the destination service
name. |
API.TransId |
send_async(String name,
byte[] request_info,
byte[] request,
Integer timeout,
Byte priority)
Asynchronous point-to-point communication to a service
subscribed that matches the destination service
name. |
API.Response |
send_sync(String name,
byte[] request)
Synchronous point-to-point communication to a service
subscribed that matches the destination service
name. |
API.Response |
send_sync(String name,
byte[] request_info,
byte[] request,
Integer timeout,
Byte priority)
Synchronous point-to-point communication to a service
subscribed that matches the destination service
name. |
void |
shutdown()
Shutdown the service successfully
|
void |
shutdown(String reason)
Shutdown the service successfully
|
int |
subscribe_count(String pattern)
Determine how may service name pattern subscriptions have occurred.
|
void |
subscribe(String pattern,
Class<?> clazz,
String methodName)
Subscribes a static method to a service name pattern.
|
void |
subscribe(String pattern,
FunctionInterface10 callback)
Subscribes a static method to a service name pattern.
|
void |
subscribe(String pattern,
FunctionInterface9 callback)
Subscribes an object method to a service name pattern.
|
void |
subscribe(String pattern,
Object instance,
String methodName)
Subscribes an object method to a service name pattern.
|
static int |
thread_count() |
int |
timeout_async() |
int |
timeout_initialize() |
int |
timeout_sync() |
int |
timeout_terminate() |
void |
unsubscribe(String pattern)
Unsubscribes from a service name pattern.
|
public static final PrintStream out
public static final PrintStream err
public static final int ASYNC
public static final int SYNC
public static final byte[] TransIdNull
public API(int thread_index)
throws API.InvalidInputException,
API.MessageDecodingException,
API.TerminateException
public static int thread_count()
throws API.InvalidInputException
API.InvalidInputException - service execution failurepublic void subscribe(String pattern, Object instance, String methodName) throws NoSuchMethodException
pattern - the service name patterninstance - the object instancemethodName - the object method to handle matching requestsNoSuchMethodException - instance method arity is invalidpublic void subscribe(String pattern, Class<?> clazz, String methodName) throws NoSuchMethodException
pattern - the service name patternclazz - the class of the static methodmethodName - the static method to handle matching requestsNoSuchMethodException - instance method arity is invalidpublic void subscribe(String pattern, FunctionInterface10 callback)
pattern - the service name patterncallback - method reference for callback (Java 8 or higher)public void subscribe(String pattern, FunctionInterface9 callback)
pattern - the service name patterncallback - method reference for callback (Java 8 or higher)public int subscribe_count(String pattern) throws API.InvalidInputException, API.TerminateException
pattern - the service name patternAPI.InvalidInputException - invalid input to internal function callAPI.TerminateException - service execution must terminatepublic void unsubscribe(String pattern) throws API.InvalidInputException
pattern - the service name patternAPI.InvalidInputException - not subscribed to service name patternpublic API.TransId send_async(String name, byte[] request) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
name.name - the destination service namerequest - the request dataAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic API.TransId send_async(String name, byte[] request_info, byte[] request, Integer timeout, Byte priority) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
name.name - the destination service namerequest_info - any request metadatarequest - the request datatimeout - the request timeout in millisecondspriority - the request priorityAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic API.Response send_sync(String name, byte[] request) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
name.name - the destination service namerequest - the request dataAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic API.Response send_sync(String name, byte[] request_info, byte[] request, Integer timeout, Byte priority) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
name.name - the destination service namerequest_info - any request metadatarequest - the request datatimeout - the request timeout in millisecondspriority - the request priorityAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic ArrayList<API.TransId> mcast_async(String name, byte[] request) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
name.name - the destination service namerequest - the request dataAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic ArrayList<API.TransId> mcast_async(String name, byte[] request_info, byte[] request, Integer timeout, Byte priority) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
name.name - the destination service namerequest_info - any request metadatarequest - the request datatimeout - the request timeout in millisecondspriority - the priority of this requestAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic void forward_(Integer request_type, String name, byte[] request_info, byte[] request, Integer timeout, Byte priority, byte[] trans_id, OtpErlangPid pid) throws API.ForwardAsyncException, API.ForwardSyncException, API.InvalidInputException
name.request_type - constant API.SYNC or API.ASYNCname - the destination service namerequest_info - any request metadatarequest - the request datatimeout - the request timeout in millisecondspriority - the priority of this requesttrans_id - the transaction IDpid - the request's source process IDAPI.ForwardAsyncException - async service request was forwardedAPI.ForwardSyncException - sync service request was forwardedAPI.InvalidInputException - invalid service request typepublic void forward_async(String name, byte[] request_info, byte[] request, Integer timeout, Byte priority, byte[] trans_id, OtpErlangPid pid) throws API.ForwardAsyncException
name.name - the destination service namerequest_info - any request metadatarequest - the request datatimeout - the request timeout in millisecondspriority - the priority of this requesttrans_id - the transaction IDpid - the request's source process IDAPI.ForwardAsyncException - async service request was forwardedpublic void forward_sync(String name, byte[] request_info, byte[] request, Integer timeout, Byte priority, byte[] trans_id, OtpErlangPid pid) throws API.ForwardSyncException
name.name - the destination service namerequest_info - any request metadatarequest - the request datatimeout - the request timeout in millisecondspriority - the priority of this requesttrans_id - the transaction IDpid - the request's source process IDAPI.ForwardSyncException - sync service request was forwardedpublic void return_(Integer request_type, String name, String pattern, byte[] response_info, byte[] response, Integer timeout, byte[] trans_id, OtpErlangPid pid) throws API.ReturnAsyncException, API.ReturnSyncException, API.InvalidInputException
request_type - constant API.SYNC or API.SYNCname - the service namepattern - the service name patternresponse_info - any response metadataresponse - the response datatimeout - the request timeout in millisecondstrans_id - the transaction IDpid - the request's source process IDAPI.ReturnAsyncException - async service request returnedAPI.ReturnSyncException - sync service request returnedAPI.InvalidInputException - invalid service request typepublic void return_async(String name, String pattern, byte[] response_info, byte[] response, Integer timeout, byte[] trans_id, OtpErlangPid pid) throws API.ReturnAsyncException
name - the service namepattern - the service name patternresponse_info - any response metadataresponse - the response datatimeout - the request timeout in millisecondstrans_id - the transaction IDpid - the request's source process IDAPI.ReturnAsyncException - async service request returnedpublic void return_sync(String name, String pattern, byte[] response_info, byte[] response, Integer timeout, byte[] trans_id, OtpErlangPid pid) throws API.ReturnSyncException
name - the service namepattern - the service name patternresponse_info - any response metadataresponse - the response datatimeout - the request timeout in millisecondstrans_id - the transaction IDpid - the request's source process IDAPI.ReturnSyncException - sync service request returnedpublic API.Response recv_async() throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
API.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic API.Response recv_async(Integer timeout) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
timeout - the receive timeout in millisecondsAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic API.Response recv_async(byte[] trans_id) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
trans_id - the transaction ID to receiveAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic API.Response recv_async(boolean consume) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
consume - if true, will consume the service request
so it is not accessible with the same function call in
the futureAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic API.Response recv_async(Integer timeout, byte[] trans_id) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
timeout - the receive timeout in millisecondstrans_id - the transaction ID to receiveAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic API.Response recv_async(Integer timeout, boolean consume) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
timeout - the receive timeout in millisecondsconsume - if true, will consume the service request
so it is not accessible with the same function call in
the futureAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic API.Response recv_async(byte[] trans_id, boolean consume) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
trans_id - the transaction ID to receiveconsume - if true, will consume the service request
so it is not accessible with the same function call in
the futureAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic API.Response recv_async(Integer timeout, byte[] trans_id, boolean consume) throws API.InvalidInputException, API.MessageDecodingException, API.TerminateException
timeout - the receive timeout in millisecondstrans_id - the transaction ID to receiveconsume - if true, will consume the service request
so it is not accessible with the same function call in
the futureAPI.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic int process_index()
public int process_count()
public int process_count_max()
public int process_count_min()
public String prefix()
public int timeout_initialize()
public int timeout_async()
public int timeout_sync()
public int timeout_terminate()
public boolean poll()
throws API.InvalidInputException,
API.MessageDecodingException,
API.TerminateException
API.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic boolean poll(int timeout)
throws API.InvalidInputException,
API.MessageDecodingException,
API.TerminateException
timeout - the block timeout in milliseconds (-1 is infinity)API.InvalidInputException - invalid input to internal function callAPI.MessageDecodingException - service messaging failureAPI.TerminateException - service execution must terminatepublic void shutdown()
public void shutdown(String reason)
reason - the shutdown reasonpublic static HashMap<String,ArrayList<String>> info_key_value_parse(byte[] info)
info - encoded binarypublic static byte[] info_key_value_new(Map<String,List<String>> pairs)
pairs - info key/value mapCopyright © 2020. All rights reserved.