Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions server/cmd/ptrun-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"syscall"
"time"

"github.com/ptr-geeks/ptrun/server/internal/consts"
"github.com/ptr-geeks/ptrun/server/internal/ws"
"go.uber.org/zap"
"goji.io"
"goji.io/pat"

"github.com/ptr-geeks/ptrun/server/internal/ws"
)

var (
Expand Down Expand Up @@ -46,12 +46,11 @@ func main() {
})

srv := &http.Server{
Handler: mux,
Addr: "0.0.0.0:8080",
// These should probably be moved under internal/const
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
IdleTimeout: 15 * time.Second,
Handler: mux,
Addr: "0.0.0.0:8080",
WriteTimeout: consts.HttpWriteTimeout,
ReadTimeout: consts.HttpReadTimeout,
IdleTimeout: consts.HttpIdleTimeout,
}

done := make(chan os.Signal, 1)
Expand Down
9 changes: 8 additions & 1 deletion server/internal/consts/consts.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package consts

import (
"time"
)

const (
ChanBufferSize = 200
ChanBufferSize = 200
HttpWriteTimeout = 15 * time.Second
HttpReadTimeout = 15 * time.Second
HttpIdleTimeout = 15 * time.Second
)
4 changes: 2 additions & 2 deletions server/internal/ws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

const (
writeTimeout = 10 * time.Second
WebSocketwriteTimeout = 10 * time.Second
)

type clientImpl struct {
Expand Down Expand Up @@ -111,7 +111,7 @@ func (c *clientImpl) SendPump() {

for message := range c.send {
// So we don't wait for too long before we send
c.conn.SetWriteDeadline(time.Now().Add(writeTimeout))
c.conn.SetWriteDeadline(time.Now().Add(WebSocketwriteTimeout))

writer, err := c.conn.NextWriter(websocket.BinaryMessage)
if err != nil {
Expand Down