LambdaClient

Abstract client that calls AWS Lambda Functions.

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.

public constructor(name: string)

  • name: string - service name.

Fields

_connection

AWS connection parameters

protected _connection: AwsConnectionParams

_connectionResolver

The connection resolver.

protected _connectionResolver: AwsConnectionResolver

_counters

Performance counters.

protected _counters: CompositeCounters

_dependencyResolver

Dependencies resolver.

protected _dependencyResolver: DependencyResolver

_lambda

Reference to AWS Lambda Function.

protected _lambda: any

_logger

Logger.

protected _logger: CompositeLogger

_opened

Opened flag.

protected _opened: boolean

_tracer

Tracer.

protected _tracer: CompositeTracer

Instance methods

call

Calls an AWS Lambda Function action.

protected T 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.

protected T 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.

public void close(IContext context)

  • context: IContext - (optional) a context to trace execution through a call chain.

configure

Configures a component by passing its configuration parameters.

public void 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.

protected InstrumentTiming 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.

protected T 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: any - action arguments
  • returns: <T> - action result.

isOpen

Checks if the component is open.

public boolean isOpen(IContext context)

  • returns: boolean - true if the component is open and false otherwise.

open

Opens the component.

public void open(IContext context)

  • context: IContext - (optional) a context to trace execution through a call chain.

setReferences

Sets references to dependent components.

public void setReferences(IReferences references) throws ReferenceException

  • references: IReferences - references to locate the component dependencies.

Examples

See also