UNPKG

3.68 kBTypeScriptView Raw
1/** @module clients */
2import { LambdaClient } from './LambdaClient';
3/**
4 * Abstract client that calls commandable AWS Lambda Functions.
5 *
6 * Commandable services are generated automatically for [[https://pip-services3-node.github.io/pip-services3-commons-node/interfaces/commands.icommandable.html ICommandable objects]].
7 * Each command is exposed as action determined by "cmd" parameter.
8 *
9 * ### Configuration parameters ###
10 *
11 * - connections:
12 * - discovery_key: (optional) a key to retrieve the connection from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]]
13 * - region: (optional) AWS region
14 * - credentials:
15 * - store_key: (optional) a key to retrieve the credentials from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/auth.icredentialstore.html ICredentialStore]]
16 * - access_id: AWS access/client id
17 * - access_key: AWS access/client id
18 * - options:
19 * - connect_timeout: (optional) connection timeout in milliseconds (default: 10 sec)
20 *
21 * ### References ###
22 *
23 * - <code>\*:logger:\*:\*:1.0</code> (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/log.ilogger.html ILogger]] components to pass log messages
24 * - <code>\*:counters:\*:\*:1.0</code> (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/count.icounters.html ICounters]] components to pass collected measurements
25 * - <code>\*:discovery:\*:\*:1.0</code> (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] services to resolve connection
26 * - <code>\*:credential-store:\*:\*:1.0</code> (optional) Credential stores to resolve credentials
27 *
28 * @see [[LambdaFunction]]
29 *
30 * ### Example ###
31 *
32 * class MyLambdaClient extends CommandableLambdaClient implements IMyClient {
33 * ...
34 *
35 * public getData(correlationId: string, id: string,
36 * callback: (err: any, result: MyData) => void): void {
37 *
38 * this.callCommand(
39 * "get_data",
40 * correlationId,
41 * { id: id },
42 * (err, result) => {
43 * callback(err, result);
44 * }
45 * );
46 * }
47 * ...
48 * }
49 *
50 * let client = new MyLambdaClient();
51 * client.configure(ConfigParams.fromTuples(
52 * "connection.region", "us-east-1",
53 * "connection.access_id", "XXXXXXXXXXX",
54 * "connection.access_key", "XXXXXXXXXXX",
55 * "connection.arn", "YYYYYYYYYYYYY"
56 * ));
57 *
58 * client.getData("123", "1", (err, result) => {
59 * ...
60 * });
61 */
62export declare class CommandableLambdaClient extends LambdaClient {
63 private _name;
64 /**
65 * Creates a new instance of this client.
66 *
67 * @param name a service name.
68 */
69 constructor(name: string);
70 /**
71 * Calls a remote action in AWS Lambda function.
72 * The name of the action is added as "cmd" parameter
73 * to the action parameters.
74 *
75 * @param cmd an action name
76 * @param correlationId (optional) transaction id to trace execution through call chain.
77 * @param params command parameters.
78 * @param callback callback function that receives result or error.
79 */
80 callCommand(cmd: string, correlationId: string, params: any, callback: (err: any, result: any) => void): void;
81}