Permalink
Browse files

Add SetMaxConn

  • Loading branch information...
nomeaning777 committed Oct 20, 2018
1 parent 9251d4f commit d487a6a16b94d9df5c782f3c461869129640e818
Showing with 5 additions and 0 deletions.
  1. +3 −0 src/isucon8/isucoin/model/order.go
  2. +1 −0 src/isucon8/isucoin/model/trade.go
  3. +1 −0 src/isucon8/isucoin/webapp/main.go
@@ -2,6 +2,7 @@ package model

import (
"database/sql"
"fmt"
"isucon8/isubank"
"time"

@@ -83,6 +84,7 @@ func FetchOrderRelation(d QueryExecutor, order *Order) error {

func AddOrder(tx *sql.Tx, ot string, userID, amount, price int64) (*Order, error) {
if amount <= 0 || price <= 0 {
fmt.Printf("Failed 87 %d, %d\n", amount, price)
return nil, ErrParameterInvalid
}
user, err := getUserByIDWithLock(tx, userID)
@@ -111,6 +113,7 @@ func AddOrder(tx *sql.Tx, ot string, userID, amount, price int64) (*Order, error
case OrderTypeSell:
// TODO 椅子の保有チェック
default:
fmt.Printf("Failed 116")
return nil, ErrParameterInvalid
}
res, err := tx.Exec(`INSERT INTO orders (type, user_id, amount, price, created_at) VALUES (?, ?, ?, ?, NOW(6))`, ot, user.ID, amount, price)
@@ -92,6 +92,7 @@ func UpdateCandleStickData(d QueryExecutor) error {
if err != nil {
return err
}
defer rows.Close()
for rows.Next() {
var ts uint64
var price int64
@@ -64,6 +64,7 @@ func main() {
if err != nil {
log.Fatalf("mysql connect failed. err: %s", err)
}
db.SetMaxOpenConns(128)
store := sessions.NewCookieStore([]byte(SessionSecret))

h := controller.NewHandler(db, store)

0 comments on commit d487a6a

Please sign in to comment.