Implements: IOpenable, IConfigurable, IReferenceable
Description
When making calls, the “cmd” parameter determines which what action shall be called, while the other parameters are passed to the action itself.
Configuration parameters
- connections:
- discovery_key: (optional) key to retrieve the connection from IDiscovery
- region: (optional) AWS region
 
- credentials:
- store_key: (optional) key to retrieve the credentials from ICredentialStore
- access_id: AWS access/client id
- access_key: AWS access/client key
 
- options:
- connect_timeout: (optional) connection timeout in milliseconds (default: 10 sec)
 
References
- *:logger:*:*:1.0 - (optional) ILogger components to pass log messages.
- *:counters:*:*:1.0 - (optional) ICounters components to pass collected measurements.
- *:discovery:*:*:1.0 - (optional) IDiscovery services to resolve connections.
- *:credential-store:*:*:1.0 - (optional) Credential stores to resolve credentials.
Constructors
Creates a new instance of this client.
publicLambdaClient(String name)
- name: string - service name.
Fields
Instance methods
call
Calls an AWS Lambda Function action.
protectedT call(TypeReference type, String cmd, IContext context, Map<String, Object> params) throws ApplicationException 
- cmd: String - action name to be called.
- context: IContext - (optional) a context to trace execution through a call chain.
- params: Map<String, Object> - (optional) action parameters.
- returns: <T> - action result.
callOneWay
Calls a AWS Lambda Function action asynchronously without waiting for response.
protectedT callOneWay(Class type, String cmd, IContext context, Map<String, Object> params) throws ApplicationException 
- cmd: String - an action name to be called.
- context: IContext - (optional) a context to trace execution through a call chain.
- params: Map<String, Object> - (optional) action parameters.
- returns: <T> - action result.
close
Closes component and frees used resources.
publicvoid close(IContext context)
- context: IContext - (optional) a context to trace execution through a call chain.
configure
Configures a component by passing its configuration parameters.
publicvoid configure(ConfigParams config) throws ConfigException
- config: ConfigParams - configuration parameters to be set.
instrument
Adds instrumentation to log calls and measures call time. It returns a InstrumentTiming object that is used to end the time measurement.
protectedInstrumentTiming instrument(IContext context, String name)
- context: IContext - (optional) a context to trace execution through a call chain.
- name: String - a method name.
- returns: InstrumentTiming - object to end the time measurement.
invoke
Performs AWS Lambda Function invocation.
protectedT invoke(Class type, String invocationType, String cmd, IContext context, Map<String, Object> args) throws ApplicationException 
- invocationType: String - invocation type: “RequestResponse” or “Event”
- cmd: String - action name to be called.
- context: IContext - (optional) a context to trace execution through a call chain.
- args: Map<String, Object> - action arguments
- returns: <T> - action result.
isOpen
Checks if the component is open.
publicboolean isOpen(IContext context)
- returns: boolean - true if the component is open and false otherwise.
open
Opens the component.
publicvoid open(IContext context)
- context: IContext - (optional) a context to trace execution through a call chain.
setReferences
Sets references to dependent components.
publicvoid setReferences(IReferences references) throws ReferenceException
- references: IReferences - references to locate the component dependencies.
Examples
class MyLambdaClient extends LambdaClient implements IMyClient {
    ...
 
    public MyData getData(IContext context, String id) {
        Timing timing = this.instrument(context, "myclient.get_data");
        MyData result = this.call(MyData.class, "get_data", context, new MyData(id));
        timing.endTiming();
        return result;
    }
    ...
}
    MyLambdaClient  client = new MyLambdaClient();
    client.configure(ConfigParams.fromTuples(
        "connection.region", "us-east-1",
        "connection.access_id", "XXXXXXXXXXX",
        "connection.access_key", "XXXXXXXXXXX",
        "connection.arn", "YYYYYYYYYYYYY"
    ));
 
    MyData result = client.getData("123", "1");