Lambda Invoke¶
An important aspect when working with Lambdas is the ability to invoke one like a remote function. The Boto3 Lambda.Client.invoke
function is one way to run your Lambda code. Smyth recognizes the need to simulate that as well.
Example¶
- Set the endpoint URL to your Smyth host and port.
- The payload being sent to the handler:
{"to": "hello@mirumee.com", "subject": "Order made"}
. - Corresponds to the TOML config
[tool.smyth.handlers.email_handler]
.
How It Works¶
No matter what url_path
your handler is registered under in your config, every handler is also available via Smyth's "/2015-03-31/functions/{function:str}/invocations"
URL. The difference from the url_path
invocation is that when using the "direct invocation," the event generator is hardcoded to the smyth.event.generate_lambda_invocation_event_data
function.
In the example above, the config might look like this:
myproject/pyproject.toml | |
---|---|
Line 9, which names the handler, is the important one here. Line 11 is required, but you don't have to use the HTTP request method to reach that handler.