Skip to content

Commit 2099508

Browse files
authored
Merge pull request goadapp#112 from cwaltken-edrans/102-break-5min-lambda-barrier
break 5min lambda barrier & other major internal refactoring
2 parents c75a2e0 + 024801e commit 2099508

File tree

9 files changed

+1131
-303
lines changed

9 files changed

+1131
-303
lines changed

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM golang:1.5
1+
FROM golang:1.8
22

33
RUN apt-get update
44
RUN apt-get install -y zip
5-
ADD . /go/src/github.com/gophergala2016/goad
6-
WORKDIR /go/src/github.com/gophergala2016/goad
7-
RUN go get -u github.com/jteeuwen/go-bindata/...
8-
RUN make bindata
9-
RUN go build -o /go/bin/goad-api webapi/webapi.go
5+
ADD . /go/src/github.com/goadapp/goad
6+
WORKDIR /go/src/github.com/goadapp/goad
7+
RUN go get -u github.com/jteeuwen/go-bindata/...
8+
RUN make linux
9+
# RUN go build -o /go/bin/goad-api webapi/webapi.go
1010

1111
CMD ["/go/bin/goad-api", "-addr", ":8080"]
1212
EXPOSE 8080

Godeps/Godeps.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
all: osx linux windows
22

3+
test:
4+
go test ./...
5+
36
lambda:
47
GOOS=linux GOARCH=amd64 go build -o data/lambda/goad-lambda ./lambda
58
zip -jr data/lambda data/lambda
@@ -21,6 +24,7 @@ windows: bindata
2124

2225
clean:
2326
rm -rf data/lambda/goad-lambda
27+
rm -rf data/lambda.zip
2428
rm -rf build
2529

2630
all-zip: all

goad.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ var supportedRegions = []string{
5656
type Test struct {
5757
Config *TestConfig
5858
infra *infrastructure.Infrastructure
59+
lambdas int
5960
}
6061

6162
// NewTest returns a configured Test
@@ -85,12 +86,13 @@ func (t *Test) Start() <-chan queue.RegionsAggData {
8586
}
8687

8788
t.infra = infra
89+
t.lambdas = numberOfLambdas(t.Config.Concurrency, len(t.Config.Regions))
8890
t.invokeLambdas(awsConfig, infra.QueueURL())
8991

9092
results := make(chan queue.RegionsAggData)
9193

9294
go func() {
93-
for result := range queue.Aggregate(awsConfig, infra.QueueURL(), t.Config.TotalRequests) {
95+
for result := range queue.Aggregate(awsConfig, infra.QueueURL(), t.Config.TotalRequests, t.lambdas) {
9496
results <- result
9597
}
9698
close(results)
@@ -100,15 +102,13 @@ func (t *Test) Start() <-chan queue.RegionsAggData {
100102
}
101103

102104
func (t *Test) invokeLambdas(awsConfig *aws.Config, sqsURL string) {
103-
lambdas := numberOfLambdas(t.Config.Concurrency, len(t.Config.Regions))
104-
105-
for i := 0; i < lambdas; i++ {
105+
for i := 0; i < t.lambdas; i++ {
106106
region := t.Config.Regions[i%len(t.Config.Regions)]
107-
requests, requestsRemainder := divide(t.Config.TotalRequests, lambdas)
108-
concurrency, _ := divide(t.Config.Concurrency, lambdas)
107+
requests, requestsRemainder := divide(t.Config.TotalRequests, t.lambdas)
108+
concurrency, _ := divide(t.Config.Concurrency, t.lambdas)
109109
execTimeout := t.Config.ExecTimeout
110110

111-
if requestsRemainder > 0 && i == lambdas-1 {
111+
if requestsRemainder > 0 && i == t.lambdas-1 {
112112
requests += requestsRemainder
113113
}
114114

@@ -129,7 +129,7 @@ func (t *Test) invokeLambdas(awsConfig *aws.Config, sqsURL string) {
129129
"-t",
130130
fmt.Sprintf("%s", c.RequestTimeout.String()),
131131
"-f",
132-
fmt.Sprintf("%s", reportingFrequency(lambdas).String()),
132+
fmt.Sprintf("%s", reportingFrequency(t.lambdas).String()),
133133
"-r",
134134
fmt.Sprintf("%s", region),
135135
"-m",
@@ -196,8 +196,8 @@ func (c TestConfig) check() error {
196196
if (c.TotalRequests < 1 && c.ExecTimeout <= 0) || c.TotalRequests > 2000000 {
197197
return errors.New("Invalid total requests (use 1 - 2000000)")
198198
}
199-
if c.ExecTimeout > 300 {
200-
return errors.New("Invalid maximum execution time in seconds (use 0 - 300)")
199+
if c.ExecTimeout > 3600 {
200+
return errors.New("Invalid maximum execution time in seconds (use 0 - 3600)")
201201
}
202202
if c.RequestTimeout.Nanoseconds() < nano || c.RequestTimeout.Nanoseconds() > nano*100 {
203203
return errors.New("Invalid timeout (1s - 100s)")

infrastructure/infrastructure.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,22 @@ func (infra *Infrastructure) createIAMLambdaRolePolicy(roleName string) error {
202202
PolicyDocument: aws.String(`{
203203
"Version": "2012-10-17",
204204
"Statement": [
205-
{
206-
"Action": [
207-
"sqs:SendMessage"
208-
],
209-
"Effect": "Allow",
210-
"Resource": "arn:aws:sqs:*:*:goad-*"
211-
},
205+
{
206+
"Action": [
207+
"sqs:SendMessage"
208+
],
209+
"Effect": "Allow",
210+
"Resource": "arn:aws:sqs:*:*:goad-*"
211+
},
212+
{
213+
"Effect": "Allow",
214+
"Action": [
215+
"lambda:Invoke*"
216+
],
217+
"Resource": [
218+
"arn:aws:lambda:*:*:goad:*"
219+
]
220+
},
212221
{
213222
"Action": [
214223
"logs:CreateLogGroup",

0 commit comments

Comments
 (0)