Interface RpcEndpointService
- All Superinterfaces:
BesuService
This service will be available during the registration callback and must be used during the registration callback. RPC endpoints are configured prior to the start callback and all endpoints connected. No endpoint will actually be called prior to the start callback so initialization unrelated to the callback registration can also be done at that time.
-
Method Summary
Modifier and TypeMethodDescriptionAllow to call any of the enabled in-process RPC methods<T> voidregisterRPCEndpoint(String namespace, String functionName, Function<PluginRpcRequest, T> function) Register a function as an RPC endpoint exposed via JSON-RPC.
-
Method Details
-
registerRPCEndpoint
<T> void registerRPCEndpoint(String namespace, String functionName, Function<PluginRpcRequest, T> function) Register a function as an RPC endpoint exposed via JSON-RPC.The mechanism is a Java function that takes a list of Strings and returns any Java object, registered in a specific namespace with a function name.
The resulting endpoint is the
namespaceand thefunctionNameconcatenated with an underscore to create the JSON-RPC method name.The function takes a
PluginRpcRequestwhich contains a list of the inputs expressed entirely as strings. Javascript numbers are converted to strings via their toString method, and complex input objects are not supported.The output is a Java object, primitive, or array that will be inspected via Jackson databind. In general if JavaBeans naming patterns are followed those names will be reflected in the returned JSON object. If the method throws an exception the return is an error with an INTERNAL_ERROR treatment.
- Type Parameters:
T- specified type of return object- Parameters:
namespace- The namespace of the method, must be alphanumeric.functionName- The name of the function, must be alphanumeric.function- The function itself.
-
call
Allow to call any of the enabled in-process RPC methods- Parameters:
methodName- the method to invokeparams- the list of parameters accepted by the method- Returns:
- the result of the method
-