Skip to content

Commit 61944c4

Browse files
committed
ensure we always close the result from the db
add some extra loggin to the errors
1 parent 328278d commit 61944c4

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.8
1+
FROM golang:1.9.2
22

33
WORKDIR /go/src/app
44
COPY . .

docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ services:
1717
restart: always
1818
ports:
1919
- "8080:8080"
20-
image: shusson/variantstore:1.3
20+
image: shusson/variantstore:1.4
2121
entrypoint: 'go-wrapper run -d "${MYSQL_ROOT_USER}:${MYSQL_ROOT_PASSWORD}@tcp(db:${MYSQL_ROOT_PORT})/variants"'

variantstore.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,20 @@ func VariantsIndex(db *sql.DB) http.HandlerFunc {
138138
response := VariantResponse{true, []Variant{}, []int{}, ""}
139139
vq, err := parse(r.URL.Query())
140140
if err != nil {
141-
errorResponse(&response, err.Error())
141+
errorResponse(&response, "Parsing Error:" + err.Error())
142142
json.NewEncoder(w).Encode(response)
143143
return
144144
}
145145

146146
count, err := countVariants(db, vq)
147147
if err != nil {
148-
errorResponse(&response, err.Error())
148+
errorResponse(&response, "Count Error:" + err.Error())
149149
json.NewEncoder(w).Encode(response)
150150
return
151151
}
152152
vs, err := queryVariants(db, vq, count)
153153
if err != nil {
154-
errorResponse(&response, err.Error())
154+
errorResponse(&response, "Query Error:" + err.Error())
155155
json.NewEncoder(w).Encode(response)
156156
return
157157
}
@@ -216,6 +216,7 @@ func queryVariants(db *sql.DB, vq VariantQuery, count int) ([]Variant, error) {
216216
if err != nil {
217217
return nil, err
218218
}
219+
defer variants.Close()
219220
var size = count - vq.Skip
220221
if size < 0 {
221222
size = 0

0 commit comments

Comments
 (0)