-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.go
More file actions
42 lines (35 loc) · 974 Bytes
/
interface.go
File metadata and controls
42 lines (35 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"context"
"sync"
fake "github.com/NextOption/aws/lambda"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/aws/session"
real "github.com/aws/aws-sdk-go/service/lambda"
)
type Serverless interface {
Invoke(in *real.InvokeInput) (out *real.InvokeOutput, err error)
InvokeWithContext(ctx context.Context, in *real.InvokeInput, opts ...request.Option) (*real.InvokeOutput, error)
}
var (
underlineLambda Serverless
one sync.Once
)
func GetServerless() Serverless {
return underlineLambda
}
func InitFakeLambda(opts ...fake.Option) {
one.Do(func() {
underlineLambda = fake.NewFakeLambda(opts...)
})
}
func InitAWSLambda() {
one.Do(func() {
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
}))
client := real.New(sess, &aws.Config{Region: aws.String("us-west-2")})
underlineLambda = client
})
}