diff --git a/api/basket.go b/api/basket.go index a3c4fe5..80a096d 100644 --- a/api/basket.go +++ b/api/basket.go @@ -3,7 +3,7 @@ package api import ( "fmt" - def "git.pbiernat.dev/egommerce/api-entities/http" + def "git.pbiernat.io/egommerce/api-entities/http" "github.com/go-redis/redis/v8" ) diff --git a/api/pricing.go b/api/pricing.go index 1e3cf46..ac9f3f5 100644 --- a/api/pricing.go +++ b/api/pricing.go @@ -3,7 +3,7 @@ package api import ( "fmt" - def "git.pbiernat.dev/egommerce/api-entities/http" + def "git.pbiernat.io/egommerce/api-entities/http" "github.com/go-redis/redis/v8" ) diff --git a/config/config.go b/config/config.go index 67c6b43..2209419 100644 --- a/config/config.go +++ b/config/config.go @@ -1,6 +1,7 @@ package config import ( + "fmt" "os" "github.com/joho/godotenv" @@ -15,7 +16,7 @@ func init() { func GetEnv(name string, defVal string) string { env := os.Getenv(name) if env == "" { - return defVal + fmt.Panicln("Missing " + name + " env variable") } return env diff --git a/consul/discovery.go b/consul/discovery.go index 0bb0ff8..1987bec 100644 --- a/consul/discovery.go +++ b/consul/discovery.go @@ -6,7 +6,7 @@ import ( "strconv" "time" - "git.pbiernat.dev/egommerce/go-api-pkg/config" + "git.pbiernat.io/egommerce/go-api-pkg/config" consul "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/connect" ) diff --git a/go.mod b/go.mod index a7d7d78..6f639ae 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ -module git.pbiernat.dev/egommerce/go-api-pkg +module git.pbiernat.io/egommerce/go-api-pkg go 1.18 require ( - git.pbiernat.dev/egommerce/api-entities v0.0.26 + git.pbiernat.io/egommerce/api-entities v0.0.26 github.com/fluent/fluent-logger-golang v1.9.0 github.com/go-redis/redis/v8 v8.11.5 github.com/hashicorp/consul v1.16.0 diff --git a/redis/cache.go b/redis/cache.go new file mode 100644 index 0000000..a82c8af --- /dev/null +++ b/redis/cache.go @@ -0,0 +1,38 @@ +package redis + +// import ( +// "context" +// "strconv" +// "time" + +// "github.com/go-redis/redis/v8" +// ) + +// func NewCache(host string, port int, password string) *redis.Client { +// redis := redis.NewClient(&redis.Options{ +// Addr: host + ":" + strconv.Itoa(port), +// Password: password, +// DB: 0, +// }) +// defer redis.Close() + +// return redis +// } + +// func Get(ctx context.Context, key string) (float64, error) { +// // ctx := context.Background() // FIXME +// price, err := s.cache.Get(ctx, key).Float64() +// if err != nil { +// s.log.Log("cache read error(key not exists): %#v", err) +// return 0, err +// } + +// return price, nil +// } + +// func Set(ctx context.Context, key string, value any, exp time.Duration) error { +// // ctx := context.Background() // FIXME +// s.cache.Set(ctx, key, value, exp) + +// return nil +// }