Documentation ¶
Index ¶
- func ConvertComandResult(comRes interface{}, prototype reflect.Type) (convRes interface{}, err error)
- type CommandableLambdaClient
- type LambdaClient
- func (c *LambdaClient) Call(prototype reflect.Type, cmd string, correlationId string, ...) (result interface{}, err error)
- func (c *LambdaClient) CallOneWay(prototype reflect.Type, cmd string, correlationId string, ...) error
- func (c *LambdaClient) Close(correlationId string) error
- func (c *LambdaClient) Configure(config *cconf.ConfigParams)
- func (c *LambdaClient) Instrument(correlationId string, name string) *ccount.CounterTiming
- func (c *LambdaClient) Invoke(prototype reflect.Type, invocationType string, cmd string, ...) (result interface{}, err error)
- func (c *LambdaClient) IsOpen() bool
- func (c *LambdaClient) Open(correlationId string) error
- func (c *LambdaClient) SetReferences(references cref.IReferences)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertComandResult ¶
func ConvertComandResult(comRes interface{}, prototype reflect.Type) (convRes interface{}, err error)
ConvertComandResult method helps get correct result from JSON by prototype Parameters:
- comRes interface{} input JSON string
- prototype reflect.Type output object prototype
Returns: convRes interface{}, err error
Types ¶
type CommandableLambdaClient ¶
type CommandableLambdaClient struct { *LambdaClient // contains filtered or unexported fields }
Abstract client that calls commandable AWS Lambda Functions.
Commandable services are generated automatically for ICommandable objects. Each command is exposed as action determined by "cmd" parameter.
### Configuration parameters ###
- connections:
- discovery_key: (optional) a key to retrieve the connection from IDiscovery
- region: (optional) AWS region
- credentials:
- store_key: (optional) a key to retrieve the credentials from ICredentialStore
- access_id: AWS access/client id
- access_key: AWS access/client id
- 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 connection - \*:credential-store:\*:\*:1.0 (optional) Credential stores to resolve credentials
See LambdaFunction ¶
### Example ###
type MyLambdaClient struct { *CommandableLambdaClient } ... func (c* MyLambdaClient) GetData(correlationId string, id string)(result MyDataPage, err error) { return c.callCommand(MyDataPageType, "get_data", correlationId, map[string]interface{}{ "id": id }) } ... client := NewMyLambdaClient(); client.Configure(NewConfigParamsFromTuples( "connection.region", "us-east-1", "connection.access_id", "XXXXXXXXXXX", "connection.access_key", "XXXXXXXXXXX", "connection.arn", "YYYYYYYYYYYYY" )); res, err := client.GetData("123", "1") ...
func NewCommandableLambdaClient ¶
func NewCommandableLambdaClient(name string) *CommandableLambdaClient
Creates a new instance of this client.
- name a service name.
func (*CommandableLambdaClient) CallCommand ¶
func (c *CommandableLambdaClient) CallCommand(prototype reflect.Type, cmd string, correlationId string, params *cdata.AnyValueMap) (result interface{}, err error)
Calls a remote action in AWS Lambda function. The name of the action is added as "cmd" parameter to the action parameters.
- prototype reflect.Type type for convert result. Set nil for return raw []byte
- cmd an action name
- correlationId (optional) transaction id to trace execution through call chain.
- params command parameters.
- Return result or error.
type LambdaClient ¶
type LambdaClient struct { // The reference to AWS Lambda Function. Lambda *lambda.Lambda // The opened flag. Opened bool // The AWS connection parameters Connection *awscon.AwsConnectionParams // The dependencies resolver. DependencyResolver *cref.DependencyResolver // The connection resolver. ConnectionResolver *awscon.AwsConnectionResolver // The logger. Logger *clog.CompositeLogger //The performance counters. Counters *ccount.CompositeCounters // The tracer. Tracer *ctrace.CompositeTracer // contains filtered or unexported fields }
Abstract client that calls AWS Lambda Functions.
When making calls "cmd" parameter determines which what action shall be called, while other parameters are passed to the action itself.
### Configuration parameters ###
- connections:
- discovery_key: (optional) a key to retrieve the connection from IDiscovery
- region: (optional) AWS region
- credentials:
- store_key: (optional) a key to retrieve the credentials from ICredentialStore
- access_id: AWS access/client id
- access_key: AWS access/client id
- 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 connection
\*:credential-store:\*:\*:1.0 (optional) Credential stores to resolve credentials
See LambdaFunction See CommandableLambdaClient
### Example ###
type MyLambdaClient struct { *LambdaClient ... } func (c* MyLambdaClient) getData(correlationId string, id string)(result MyData, err error){ timing := c.Instrument(correlationId, "myclient.get_data"); callRes, callErr := c.Call(MyDataPageType ,"get_data" correlationId, map[string]interface{ "id": id }) timing.EndTiming(); return callRes, callErr } ... client = NewMyLambdaClient(); client.Configure(NewConfigParamsFromTuples( "connection.region", "us-east-1", "connection.access_id", "XXXXXXXXXXX", "connection.access_key", "XXXXXXXXXXX", "connection.arn", "YYYYYYYYYYYYY" )); data, err := client.GetData("123", "1",) ...
func NewLambdaClient ¶
func NewLambdaClient() *LambdaClient
func (*LambdaClient) Call ¶
func (c *LambdaClient) Call(prototype reflect.Type, cmd string, correlationId string, params map[string]interface{}) (result interface{}, err error)
Calls a AWS Lambda Function action.
- prototype reflect.Type type for convert result. Set nil for return raw []byte
- cmd an action name to be called.
- correlationId (optional) transaction id to trace execution through call chain.
- params (optional) action parameters.
- Returns result and error.
func (*LambdaClient) CallOneWay ¶
func (c *LambdaClient) CallOneWay(prototype reflect.Type, cmd string, correlationId string, params map[string]interface{}) error
Calls a AWS Lambda Function action asynchronously without waiting for response.
- prototype reflect.Type type for convert result. Set nil for return raw []byte
- cmd an action name to be called.
- correlationId (optional) transaction id to trace execution through call chain.
- params (optional) action parameters.
- Returns error or null for success.
func (*LambdaClient) Close ¶
func (c *LambdaClient) Close(correlationId string) error
Closes component and frees used resources.
- correlationId (optional) transaction id to trace execution through call chain.
- Returns error or null no errors occured.
func (*LambdaClient) Configure ¶
func (c *LambdaClient) Configure(config *cconf.ConfigParams)
Configures component by passing configuration parameters.
- config configuration parameters to be set.
func (*LambdaClient) Instrument ¶
func (c *LambdaClient) Instrument(correlationId string, name string) *ccount.CounterTiming
Adds instrumentation to log calls and measure call time. It returns a Timing object that is used to end the time measurement.
- correlationId (optional) transaction id to trace execution through call chain.
- name a method name. Returns Timing object to end the time measurement.
func (*LambdaClient) IsOpen ¶
func (c *LambdaClient) IsOpen() bool
Checks if the component is opened. Returns true if the component has been opened and false otherwise.
func (*LambdaClient) Open ¶
func (c *LambdaClient) Open(correlationId string) error
Opens the component.
- correlationId (optional) transaction id to trace execution through call chain.
- Return error or nil no errors occured.
func (*LambdaClient) SetReferences ¶
func (c *LambdaClient) SetReferences(references cref.IReferences)
Sets references to dependent components.
- references references to locate the component dependencies.