loader cache config
This commit is contained in:
parent
0971301562
commit
a10593a318
@ -23,11 +23,18 @@ type Loader struct {
|
||||
listBucketsLoaderCache cache.S3Cache
|
||||
}
|
||||
|
||||
func NewLoader(config types.AppConfig) *Loader {
|
||||
listObjectsLoaderCache := &dataloader.NoCache{}
|
||||
listObjectsRecursiveLoaderCache := &dataloader.NoCache{}
|
||||
statObjectLoaderCache := cache.NewTTLCache(config.CacheTTL, config.CacheCleanup)
|
||||
listBucketsLoaderCache := cache.NewTTLCache(config.CacheTTL, config.CacheCleanup)
|
||||
type CacheConfig struct {
|
||||
ListObjectsLoaderCache cache.S3Cache
|
||||
ListObjectsRecursiveLoaderCache cache.S3Cache
|
||||
StatObjectLoaderCache cache.S3Cache
|
||||
ListBucketsLoaderCache cache.S3Cache
|
||||
}
|
||||
|
||||
func NewLoader(cacheConfig CacheConfig) *Loader {
|
||||
listObjectsLoaderCache := cacheConfig.ListObjectsLoaderCache
|
||||
listObjectsRecursiveLoaderCache := cacheConfig.ListObjectsRecursiveLoaderCache
|
||||
statObjectLoaderCache := cacheConfig.StatObjectLoaderCache
|
||||
listBucketsLoaderCache := cacheConfig.ListBucketsLoaderCache
|
||||
|
||||
return &Loader{
|
||||
listObjectsLoader: dataloader.NewBatchedLoader(
|
||||
|
@ -3,8 +3,10 @@ package s3browser
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/graph-gophers/dataloader"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"git.kapelle.org/niklas/s3browser/internal/cache"
|
||||
"git.kapelle.org/niklas/s3browser/internal/db"
|
||||
gql "git.kapelle.org/niklas/s3browser/internal/gql"
|
||||
httpserver "git.kapelle.org/niklas/s3browser/internal/httpserver"
|
||||
@ -33,7 +35,12 @@ func Start(config types.AppConfig) {
|
||||
log.Error("Failed to connect DB: ", err.Error())
|
||||
}
|
||||
|
||||
loader := loader.NewLoader(config)
|
||||
loader := loader.NewLoader(loader.CacheConfig{
|
||||
ListObjectsLoaderCache: &dataloader.NoCache{},
|
||||
ListObjectsRecursiveLoaderCache: &dataloader.NoCache{},
|
||||
StatObjectLoaderCache: cache.NewTTLCache(config.CacheTTL, config.CacheCleanup),
|
||||
ListBucketsLoaderCache: cache.NewTTLCache(config.CacheTTL, config.CacheCleanup),
|
||||
})
|
||||
|
||||
gql.GraphqlTypes()
|
||||
schema, err := gql.GraphqlSchema()
|
||||
|
Loading…
Reference in New Issue
Block a user