Skip to content

Commit

Permalink
Fix cache (#68)
Browse files Browse the repository at this point in the history
* remove swag stuff

* more fixes
  • Loading branch information
decentralgabe authored Dec 5, 2023
1 parent 2af64d8 commit 1286c9b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 30 deletions.
26 changes: 0 additions & 26 deletions impl/docs/docs.go

This file was deleted.

2 changes: 1 addition & 1 deletion impl/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func Spec() error {
return err
}

return sh.Run(swagCommand, "init", "-g", "cmd/main.go", "--overridesFile", "docs/overrides.swaggo", "--pd", "--parseInternal", "-ot", "go,yaml")
return sh.Run(swagCommand, "init", "-g", "cmd/main.go", "--overridesFile", "docs/overrides.swaggo", "--pd", "--parseInternal", "-ot", "yaml")
}

func ColorizeTestOutput(w io.Writer) io.Writer {
Expand Down
3 changes: 0 additions & 3 deletions impl/pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"

"github.com/TBD54566975/did-dht-method/config"
"github.com/TBD54566975/did-dht-method/docs"
"github.com/TBD54566975/did-dht-method/pkg/service"
"github.com/TBD54566975/did-dht-method/pkg/storage"
)
Expand Down Expand Up @@ -52,8 +51,6 @@ func NewServer(cfg *config.Config, shutdown chan os.Signal) (*Server, error) {
handler.GET("/health", Health)

// set up swagger
docs.SwaggerInfo.Host = fmt.Sprintf("%s:%d", cfg.ServerConfig.APIHost, cfg.ServerConfig.APIPort)
docs.SwaggerInfo.Version = "0.0.1"
handler.StaticFile("swagger.yaml", "./docs/swagger.yaml")
handler.GET("/swagger/*any", ginswagger.WrapHandler(swaggerfiles.Handler, ginswagger.URL("/swagger.yaml")))

Expand Down
3 changes: 3 additions & 0 deletions impl/pkg/service/pkarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/TBD54566975/did-dht-method/pkg/storage"
)

const recordSizeLimit = 1000

// PkarrService is the Pkarr service responsible for managing the Pkarr DHT and reading/writing records
type PkarrService struct {
cfg *config.Config
Expand All @@ -45,6 +47,7 @@ func NewPkarrService(cfg *config.Config, db *storage.Storage) (*PkarrService, er
// create and start cache and scheduler
cacheTTL := time.Duration(cfg.PkarrConfig.CacheTTLSeconds) * time.Second
cacheConfig := bigcache.DefaultConfig(cacheTTL)
cacheConfig.MaxEntrySize = recordSizeLimit
cacheConfig.HardMaxCacheSize = cfg.PkarrConfig.CacheSizeLimitMB
cache, err := bigcache.New(context.Background(), cacheConfig)
if err != nil {
Expand Down

0 comments on commit 1286c9b

Please sign in to comment.