Compare commits

...

2 Commits

Author SHA1 Message Date
081e1edd24 go.mod update priv git url 2024-05-30 17:16:39 +02:00
c454307d56 consul fixes 2024-04-19 19:17:09 +02:00
6 changed files with 46 additions and 7 deletions

View File

@@ -3,7 +3,7 @@ package api
import ( import (
"fmt" "fmt"
def "git.pbiernat.dev/egommerce/api-entities/http" def "git.pbiernat.io/egommerce/api-entities/http"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
) )

View File

@@ -3,7 +3,7 @@ package api
import ( import (
"fmt" "fmt"
def "git.pbiernat.dev/egommerce/api-entities/http" def "git.pbiernat.io/egommerce/api-entities/http"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
) )

View File

@@ -1,6 +1,7 @@
package config package config
import ( import (
"fmt"
"os" "os"
"github.com/joho/godotenv" "github.com/joho/godotenv"
@@ -15,7 +16,7 @@ func init() {
func GetEnv(name string, defVal string) string { func GetEnv(name string, defVal string) string {
env := os.Getenv(name) env := os.Getenv(name)
if env == "" { if env == "" {
return defVal fmt.Panicln("Missing " + name + " env variable")
} }
return env return env

View File

@@ -6,7 +6,7 @@ import (
"strconv" "strconv"
"time" "time"
"git.pbiernat.dev/egommerce/go-api-pkg/config" "git.pbiernat.io/egommerce/go-api-pkg/config"
consul "github.com/hashicorp/consul/api" consul "github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/connect" "github.com/hashicorp/consul/connect"
) )
@@ -180,7 +180,7 @@ func (s *Service) getTags() []string {
"traefik.enable=true", "traefik.enable=true",
"traefik.http.routers." + s.Name + ".rule=PathPrefix(`" + s.pathPrefix + "`)", "traefik.http.routers." + s.Name + ".rule=PathPrefix(`" + s.pathPrefix + "`)",
"traefik.http.routers." + s.Name + ".entryPoints=https", "traefik.http.routers." + s.Name + ".entryPoints=https",
"traefik.http.routers." + s.Name + ".tls=true", // "traefik.http.routers." + s.Name + ".tls=true",
"traefik.http.routers." + s.Name + ".service=" + s.Name, "traefik.http.routers." + s.Name + ".service=" + s.Name,
"traefik.http.routers." + s.Name + ".middlewares=auth_" + s.Name + ",requestid_" + s.Name + ",stripprefix_" + s.Name, "traefik.http.routers." + s.Name + ".middlewares=auth_" + s.Name + ",requestid_" + s.Name + ",stripprefix_" + s.Name,
"traefik.http.services." + s.Name + ".loadbalancer.server.scheme=http", "traefik.http.services." + s.Name + ".loadbalancer.server.scheme=http",

4
go.mod
View File

@@ -1,9 +1,9 @@
module git.pbiernat.dev/egommerce/go-api-pkg module git.pbiernat.io/egommerce/go-api-pkg
go 1.18 go 1.18
require ( 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/fluent/fluent-logger-golang v1.9.0
github.com/go-redis/redis/v8 v8.11.5 github.com/go-redis/redis/v8 v8.11.5
github.com/hashicorp/consul v1.16.0 github.com/hashicorp/consul v1.16.0

38
redis/cache.go Normal file
View File

@@ -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
// }