public class Farcall
extends java.lang.Object
Cross-platform fast, simple and elegant RPC protocol. Supports function calls with typed arguments (any that Connector supports), as arrays, keywords or both, return values and remote exceptions.
Protocol description can be found here: https://github.com/sergeych/farcall/wiki along with the corresponding ruby gem.
Created by sergeych on 10.04.16.
| Modifier and Type | Class and Description |
|---|---|
class |
Farcall.CommandResult
Deferred result of the Farcall command execution, to be used inside the farcall package.
|
static class |
Farcall.RemoteException
The exception information that was passed from the remote party, while executing some command.
|
static interface |
Farcall.Target |
| Constructor and Description |
|---|
Farcall(Connector connector)
Create Farcall connected to some endpoint.
|
| Modifier and Type | Method and Description |
|---|---|
void |
asyncCommands()
Allow farcall to use own ExecutorSerice to run commands in parallel.
|
void |
asyncCommands(java.util.concurrent.ExecutorService service)
Let farcall execute remote comands in the executor service.
|
void |
close() |
boolean |
isClosed() |
Farcall.CommandResult |
send(java.lang.String name)
Send command without parameters
|
Farcall.CommandResult |
send(java.lang.String name,
java.util.ArrayList<java.lang.Object> params,
java.util.HashMap<java.lang.String,java.lang.Object> keyParams)
Send remote command with all kind of parameters
|
Farcall.CommandResult |
sendKeyParams(java.lang.String name,
java.lang.Object... keysAndValues)
Send remote command with only keyed parameters.
|
Farcall.CommandResult |
sendParams(java.lang.String name,
java.lang.Object... params)
Send Farcall command to the remote with only array parameters.
|
void |
start()
Start the protocol in one-way mode: this instance only issues commands.
|
void |
start(Farcall.Target target)
Start a worker thread that reads connector data, and executes recevied commamds using specified interface.
|
public Farcall(Connector connector)
start() or start(Target).connector - public void asyncCommands(java.util.concurrent.ExecutorService service)
Farcall.Target.onCommand(Command) will
be executed using this service (what means, most often, asynchronouly.service - to use. Call with null to resore synchronous operations.public void asyncCommands()
Farcall.Target.onCommand(Command) will
be executed using this service asynchronouly.public void start(Farcall.Target target)
target - callback to process incoming commandspublic void start()
public boolean isClosed()
public Farcall.CommandResult send(java.lang.String name)
name - of the commandpublic Farcall.CommandResult send(java.lang.String name, java.util.ArrayList<java.lang.Object> params, java.util.HashMap<java.lang.String,java.lang.Object> keyParams)
name - of the commandparams - array parameters or nullkeyParams - map parameters or nullpublic Farcall.CommandResult sendParams(java.lang.String name, java.lang.Object... params)
DeferredResult instance.name - command nameparams - array parameterspublic Farcall.CommandResult sendKeyParams(java.lang.String name, java.lang.Object... keysAndValues)
farcall.sendKeyParams("foo", "param1", 10, "param2", 20, "bar", "baz")
The return value being passed via DeferredResult is either data returned by the remote party, e.g. List, Map, simple types, strings, or whatever else Connector allows, or, in the case
the remote throws and error, instance of the Farcall.RemoteException class.name - keysAndValues - key1, value1, key2, value2... sequencepublic void close()