Skip to content
Snippets Groups Projects

Resolve "Create cache GET endpoint"

Merged Yordan Kinkov requested to merge 2-implement-cache-get-endpoint into main
84 files
+ 1000
6
Compare changes
  • Side-by-side
  • Inline
Files
84
+ 14
0
@@ -14,12 +14,16 @@ import (
goa "goa.design/goa/v3/pkg"
"golang.org/x/sync/errgroup"
goacache "code.vereign.com/gaiax/tsa/cache/gen/cache"
goahealth "code.vereign.com/gaiax/tsa/cache/gen/health"
goacachesrv "code.vereign.com/gaiax/tsa/cache/gen/http/cache/server"
goahealthsrv "code.vereign.com/gaiax/tsa/cache/gen/http/health/server"
goaopenapisrv "code.vereign.com/gaiax/tsa/cache/gen/http/openapi/server"
"code.vereign.com/gaiax/tsa/cache/gen/openapi"
"code.vereign.com/gaiax/tsa/cache/internal/clients/redis"
"code.vereign.com/gaiax/tsa/cache/internal/config"
"code.vereign.com/gaiax/tsa/cache/internal/service"
"code.vereign.com/gaiax/tsa/cache/internal/service/cache"
"code.vereign.com/gaiax/tsa/cache/internal/service/health"
"code.vereign.com/gaiax/tsa/golib/graceful"
)
@@ -40,20 +44,27 @@ func main() {
logger.Info("start cache service", zap.String("version", Version), zap.String("goa", goa.Version()))
// create redis client
redis := redis.New(cfg.Redis.Addr, cfg.Redis.User, cfg.Redis.Pass, cfg.Redis.DB, cfg.Redis.TTL)
// create services
var (
cacheSvc goacache.Service
healthSvc goahealth.Service
)
{
cacheSvc = cache.New(redis, logger)
healthSvc = health.New()
}
// create endpoints
var (
cacheEndpoints *goacache.Endpoints
healthEndpoints *goahealth.Endpoints
openapiEndpoints *openapi.Endpoints
)
{
cacheEndpoints = goacache.NewEndpoints(cacheSvc)
healthEndpoints = goahealth.NewEndpoints(healthSvc)
openapiEndpoints = openapi.NewEndpoints(nil)
}
@@ -72,15 +83,18 @@ func main() {
mux := goahttp.NewMuxer()
var (
cacheServer *goacachesrv.Server
healthServer *goahealthsrv.Server
openapiServer *goaopenapisrv.Server
)
{
cacheServer = goacachesrv.New(cacheEndpoints, mux, dec, enc, nil, errFormatter)
healthServer = goahealthsrv.New(healthEndpoints, mux, dec, enc, nil, errFormatter)
openapiServer = goaopenapisrv.New(openapiEndpoints, mux, dec, enc, nil, errFormatter, nil, nil)
}
// Configure the mux.
goacachesrv.Mount(mux, cacheServer)
goahealthsrv.Mount(mux, healthServer)
goaopenapisrv.Mount(mux, openapiServer)
Loading