CommandableLambdaFunction

Abstract AWS Lambda function that acts as a container to instantiate and run components and expose them via an external entry point.

Implements: LambdaFunction

Description

The CommandableLambdaFunction class allows you to create AWS Lambda functions that acts as containers to instantiate and run components and expose them via an external entry point.

Important points

  • All actions are automatically generated for commands defined in ICommandable components. Each command is exposed as an action defined by the “cmd” parameter.

  • Container configuration for this Lambda function is stored in "./config/config.yml" file. But this path can be overriden by CONFIG_PATH environment variable.

  • Note: This component has been deprecated. Use LambdaService instead.

Configuration parameters

  • dependencies:
    • controller: override for Controller dependency
  • 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

References

  • *:logger:*:*:1.0: (optional) ILogger components to pass log messages.
  • *:counters:*:*:1.0: (optional) ICounters components to pass collected measurements.
  • *:service:lambda:*:1.0: (optional) ILambdaController services to handle action requests
  • *:service:commandable-lambda:*:1.0: (optional) ILambdaController services to handle action requests

Constructors

NewCommandableLambdaFunction

Creates a new instance of this lambda function.

NewCommandableLambdaFunction(name string, description string) *CommandableLambdaFunction

  • name: string - (optional) container name (accessible via ContextInfo)
  • description: string - (optional) container description (accessible via ContextInfo).

Methods

Register

Registers all actions in this lambda function.

(c *CommandableLambdaFunction) Register()

Examples

type MyCommandableLambdaFunction struct {
	*awscont.CommandableLambdaFunction
}

func NewMyCommandableLambdaFunction() *MyCommandableLambdaFunction {
	c := &MyCommandableLambdaFunction{}
	c.CommandableLambdaFunction = awscont.NewCommandableLambdaFunction("my_group", "My data lambda function")

	c.DependencyResolver.Put(context.Background(), "controller", cref.NewDescriptor("my-group", "controller", "default", "*", "*"))
	c.AddFactory(awstest.NewDummyFactory())
	return c
}

lambda := NewMyCommandableLambdaFunction();

lambda.Run(context.Context())

See also