mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-07-04 07:22:21 +02:00
Compare commits
3 Commits
59ea469fb6
...
fadd10602a
Author | SHA1 | Date | |
---|---|---|---|
|
fadd10602a | ||
|
e4de7c2391 | ||
|
de0bd74dc2 |
@ -18,6 +18,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@ -280,6 +281,10 @@ func handleSaveData(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case "/savedata/get":
|
||||
save, err = savedata.Get(uuid, datatype, slot)
|
||||
if err == sql.ErrNoRows {
|
||||
http.Error(w, err.Error(), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
case "/savedata/update":
|
||||
err = savedata.Update(uuid, slot, save)
|
||||
case "/savedata/delete":
|
||||
|
13
db/db.go
13
db/db.go
@ -38,10 +38,15 @@ func Init(username, password, protocol, address, database string) error {
|
||||
return fmt.Errorf("failed to open database connection: %s", err)
|
||||
}
|
||||
|
||||
handle.SetMaxIdleConns(256)
|
||||
handle.SetMaxOpenConns(256)
|
||||
handle.SetConnMaxIdleTime(time.Second * 30)
|
||||
handle.SetConnMaxLifetime(time.Minute)
|
||||
conns := 1024
|
||||
if protocol != "unix" {
|
||||
conns = 256
|
||||
}
|
||||
|
||||
handle.SetMaxOpenConns(conns)
|
||||
handle.SetMaxIdleConns(conns/4)
|
||||
|
||||
handle.SetConnMaxIdleTime(time.Second * 10)
|
||||
|
||||
tx, err := handle.Begin()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user