From 92fb8356f1ccaa8681ffbb8839a2661bfc458e5e Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Mon, 15 Nov 2021 16:33:31 +0100 Subject: [PATCH] [fix] Changed module name --- go.mod | 2 +- pkg/cache/cache.go | 2 +- pkg/cache/redis_datastore.go | 3 +-- pkg/main.go | 4 ++-- pkg/server/router.go | 9 ++++----- pkg/server/server.go | 19 +++++++++---------- 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 6a06123..3a51d08 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module vegvisir +module git.pbiernat.dev/golang/vegvisir go 1.17 diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 3fcc09a..003075d 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -10,8 +10,8 @@ package cache import ( + "git.pbiernat.dev/golang/vegvisir/pkg/config" "log" - "vegvisir/pkg/config" ) const ( diff --git a/pkg/cache/redis_datastore.go b/pkg/cache/redis_datastore.go index fc95486..71a557b 100644 --- a/pkg/cache/redis_datastore.go +++ b/pkg/cache/redis_datastore.go @@ -10,12 +10,11 @@ package cache import ( + "github.com/go-redis/redis" "log" "os" "strconv" "time" - - "github.com/go-redis/redis" ) // NewRedisDatastore function diff --git a/pkg/main.go b/pkg/main.go index 7b882e0..dabfa7a 100644 --- a/pkg/main.go +++ b/pkg/main.go @@ -11,14 +11,14 @@ package main import ( "flag" + "git.pbiernat.dev/golang/vegvisir/pkg/server" "log" "net/http" + _ "net/http/pprof" "os" "runtime" "runtime/pprof" - "vegvisir/pkg/server" ) -import _ "net/http/pprof" var ( cPath = flag.String("c", "vegvisir.json", "Path to config file") diff --git a/pkg/server/router.go b/pkg/server/router.go index aff96e2..969f5f4 100644 --- a/pkg/server/router.go +++ b/pkg/server/router.go @@ -1,4 +1,3 @@ - // ___ ____ ___ ___ // \ \ / / | _ | __| \ \ / / || | __ || || _ | // \ \/ / |___ | |__ \ \/ / || |___ || ||___| @@ -12,18 +11,18 @@ package server import ( "fmt" + "git.pbiernat.dev/golang/vegvisir/pkg/cache" + "git.pbiernat.dev/golang/vegvisir/pkg/config" "log" "regexp" "strings" - "vegvisir/pkg/cache" - "vegvisir/pkg/config" ) // Router struct type Router struct { config *config.Config //cache map[string]cache.RouteCache - cache *cache.MemoryDatastore + cache *cache.MemoryDatastore //cache *cache.RedisDatastore } @@ -65,7 +64,7 @@ func (r *Router) FindByRequestURL(url []byte) (bool, *cache.RouteCache) { //routeJSON, _ := ffjson.Marshal(&route) // FIXME: TMP - if err := r.cache.SetKey("route_" + sURL, route, r.config.Cache.RouteTTL); err != nil { + if err := r.cache.SetKey("route_"+sURL, route, r.config.Cache.RouteTTL); err != nil { // FIXME: ^^ use cache.Manager* after refactor log.Println("Error saving route cache:", sURL) } diff --git a/pkg/server/server.go b/pkg/server/server.go index 3589af4..76d1fab 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -12,15 +12,14 @@ package server import ( "context" "fmt" + "git.pbiernat.dev/golang/vegvisir/pkg/cache" + "git.pbiernat.dev/golang/vegvisir/pkg/config" + "github.com/valyala/fasthttp" "log" "os" "os/signal" "syscall" "time" - "vegvisir/pkg/cache" - "vegvisir/pkg/config" - - "github.com/valyala/fasthttp" ) const ( @@ -65,12 +64,12 @@ func (s *Server) Run() { go func() { serverAddress := s.config.Server.Address + ":" + fmt.Sprint(s.config.Server.Port) s.daemon = &fasthttp.Server{ - Handler: s.mainHandler, - ReadTimeout: 15 * time.Second, - WriteTimeout: 20 * time.Second, - MaxConnsPerIP: 500, - MaxRequestsPerConn: 500, - IdleTimeout: 15 * time.Second, // aka KeepAlive + Handler: s.mainHandler, + ReadTimeout: 15 * time.Second, + WriteTimeout: 20 * time.Second, + MaxConnsPerIP: 500, + MaxRequestsPerConn: 500, + IdleTimeout: 15 * time.Second, // aka KeepAlive //CloseOnShutdown: true, }