Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AWS Lambda GoLang处理程序API_Go_Aws Lambda_Amazon Kinesis - Fatal编程技术网

AWS Lambda GoLang处理程序API

AWS Lambda GoLang处理程序API,go,aws-lambda,amazon-kinesis,Go,Aws Lambda,Amazon Kinesis,是否可以使用自定义API实现Lambda函数处理程序 对于aws lambda go,有效的处理程序是以下类型之一: // func () // func () error // func (TIn) error // func () (TOut, error) // func (TIn) (TOut, error) // func (context.Context) error // func (context.Context, TIn) error // func (cont

是否可以使用自定义API实现Lambda函数处理程序

对于aws lambda go,有效的处理程序是以下类型之一:

//  func ()
//  func () error
//  func (TIn) error
//  func () (TOut, error)
//  func (TIn) (TOut, error)
//  func (context.Context) error
//  func (context.Context, TIn) error
//  func (context.Context) (TOut, error)
//  func (context.Context, TIn) (TOut, error)
在我的例子中,
TIn
是包含
MySpecificType
作为有效负载的KinesEvent。 我正在寻找能够创建类型为的处理程序的方法(可能覆盖
lambda.Start()

func(MySpecificType) error

目标是避免在每个lambda中从kinisevent中提取有效负载,并使处理程序源独立

看起来解决方案非常简单。只需覆盖lambda.Start()方法:

然后:

// main.go
func Handler(m *MySpecificType, index int) error {
// ...
}

func main() {
    <wherever_you_put_it_package>.Start(Handler)
    // instead of lambda.Start(Handler)
}
//main.go
func处理程序(m*MySpecificType,index int)错误{
// ...
}
func main(){
.Start(处理程序)
//而不是lambda.Start(处理程序)
}
// main.go
func Handler(m *MySpecificType, index int) error {
// ...
}

func main() {
    <wherever_you_put_it_package>.Start(Handler)
    // instead of lambda.Start(Handler)
}