dongse7261 2018-09-10 16:06
浏览 40

接收lambda InvokeInput的lambda的方法签名是什么?

I'd like to get my two lambdas to communicate with each other. Lambda A uses InvokeInput, passing Payload as used in the example here:

https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/go/example_code/lambda/aws-go-sdk-lambda-example-run-function.go

However, the example doesn't show the receiving end i.e Lambda B. I'm trying to access Payload, so I've tried a handler with the method signatures:

func Handler(ctx context.Context, lambdaInput messages.InvokeRequest) (api.Response, error)

as well as

func Handler(ctx context.Context, lambdaInput lambda.InvokeInput) (api.Response, error)

When calling lambdaInput.Payload on the former it returns [] despite what's being sent as a payload.

I am unable to find the documentation on this, does anyone know the proper signature that I should be using?

  • 写回答

1条回答 默认 最新

  • drtj40036 2018-09-10 16:51
    关注

    From AWS docuentation:https://docs.aws.amazon.com/lambda/latest/dg/go-programming-model-handler-types.html

    The following lists valid handler signatures. TIn and TOut represent types compatible with the encoding/json standard library. For more information, see func Unmarshal to learn how these types are deserialized.

    func ()
    func () error
    func (TIn), error
    func () (TOut, error)
    func (context.Context) error
    func (context.Context, TIn) error
    func (context.Context) (TOut, error)
    func (context.Context, TIn) (TOut, error)
    

    So it depends on what is in your payload. AWS will try to deserialize your data and match it with the TIn parameter in your function. There are already some types that represent AWS Event types, but in your case you should write your own struct. Check the link for some examples.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?