Move into api routers instead of main

This commit is contained in:
2022-02-16 16:27:48 +01:00
parent f35f277b16
commit c3946df1ff
16 changed files with 561 additions and 358 deletions

View File

@@ -0,0 +1,29 @@
package dependencies
import (
"github.com/dgraph-io/ristretto"
"github.com/eko/gocache/cache"
"github.com/eko/gocache/metrics"
"github.com/eko/gocache/store"
"go.uber.org/zap"
)
func setupCache(l *zap.Logger) *cache.MetricCache {
l.Info("Setting up Cache")
ristrettoCache, err := ristretto.NewCache(&ristretto.Config{
NumCounters: 1000,
MaxCost: 100_000_000,
BufferItems: 64,
})
promMetrics := metrics.NewPrometheus("serverctl")
if err != nil {
panic(err)
}
ristrettoStore := store.NewRistretto(ristrettoCache, nil)
cacheManager := cache.New(ristrettoStore)
metricsCache := cache.NewMetric(promMetrics, cacheManager)
return metricsCache
}