pip_services3_aws.services.LambdaService module
- class pip_services3_aws.services.LambdaService.LambdaService(name: Optional[str] = None)
Bases:
pip_services3_aws.services.ILambdaService.ILambdaService,pip_services3_commons.run.IOpenable.IOpenable,pip_services3_commons.config.IConfigurable.IConfigurable,pip_services3_commons.refer.IReferenceable.IReferenceable,abc.ABCAbstract service that receives remove calls via AWS Lambda protocol.
This service is intended to work inside LambdaFunction container that exploses registered actions externally.
- ### Configuration parameters ###
- dependencies:
controller: override for Controller dependency
- ### References ###
*:logger:*:*:1.0 (optional)
ILoggercomponents to pass log messages*:counters:*:*:1.0 (optional)
ICounterscomponents to pass collected measurements
Example:
class MyLambdaService(LambdaService): _controller: IMyController ... def __init__(self): super().__init__('v1.myservice') self._dependency_resolver.put( "controller", Descriptor("mygroup","controller","*","*","1.0") ) def set_references(self, references: IReferences): super().set_references(references) self._controller = self._dependency_resolver.get_required("controller") def __action(self, params): correlation_id = params.get('correlation_id') id = params.get('id') return self._controller.get_my_data(correlationId, id) def register(self): self.register_action("get_my_data", None, __action) ... service = MyLambdaService() service.configure(ConfigParams.from_tuples( "connection.protocol", "http", "connection.host", "localhost", "connection.port", 8080 )) service.set_references(References.from_tuples( Descriptor("mygroup","controller","default","default","1.0"), controller )) service.open("123")
- act(params: dict) Any
Calls registered action in this lambda function. “cmd” parameter in the action parameters determin what action shall be called.
This method shall only be used in testing.
- Parameters
params – action parameters.
- close(correlation_id: Optional[str])
Closes component and frees used resources.
- Parameters
correlation_id – (optional) transaction id to trace execution through call chain.
- configure(config: pip_services3_commons.config.ConfigParams.ConfigParams)
Configures component by passing configuration parameters.
- Parameters
config – configuration parameters to be set.
- get_actions() List[pip_services3_aws.services.LambdaAction.LambdaAction]
Get all actions supported by the service.
- Returns
an array with supported actions.
- is_open() bool
Checks if the component is opened.
- Returns
true if the component has been opened and false otherwise.
- open(correlation_id: Optional[str])
Opens the component.
- Parameters
correlation_id – (optional) transaction id to trace execution through call chain.
- abstract register()
Registers all service routes in HTTP endpoint.
This method is called by the service and must be overriden in child classes.
- set_references(references: pip_services3_commons.refer.IReferences.IReferences)
Sets references to dependent components.
- Parameters
references – references to locate the component dependencies.