dsiv4041 2018-03-22 05:07
浏览 31
已采纳

一个Go二进制文件中可能有多个lambda函数吗?

I am experimenting with Go on AWS lambda, and i found that each function requires a binary to be uploaded for execution.

My question is that, is it possible to have a single binary that can have two different Handler functions, which can be loaded by two different lambda functions.

for example

func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
    fmt.Println("Received body in Handler 1: ", request.Body)

    return events.APIGatewayProxyResponse{Body: request.Body, StatusCode: 200}, nil
}
func Handler1(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
    fmt.Println("Received body in Handler 2: ", request.Body)

    return events.APIGatewayProxyResponse{Body: request.Body, StatusCode: 200}, nil
}

func EndPoint1() {
    lambda.Start(Handler)
}
func EndPoint2() {
    lambda.Start(Handler1)
}

and calling the EndPoints in main in such a way that it registers both the EndPoints and the same binary would be uploaded to both the functions MyFunction1 and MyFunction2.

I understand that having two different binary is good because it reduces the load/size of each function.

But this is just an experimentation.

Thanks in advance :)

  • 写回答

2条回答 默认 最新

  • dongliao9233 2018-03-22 18:15
    关注

    I believe it is not possible since Lambda console says the handler is the name of the executable file:

    Handler: The executable file name value. For example, "myHandler" would call the main function in the package “main” of the myHandler executable program.

    So one single executable file is unable to host two different handlers.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

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