feat: self-bootstrapping tracker, jetstream updates

* This removes redis as a hard dependency
* add profiler utils (temp)
This commit is contained in:
2024-10-31 14:52:51 +03:00
parent e03dabdf0f
commit 75b402bbf6
9 changed files with 85 additions and 93 deletions

View File

@@ -3,6 +3,8 @@ package cache
import (
"context"
"log/slog"
"github.com/grassrootseconomics/eth-tracker/internal/chain"
)
type (
@@ -14,9 +16,13 @@ type (
}
CacheOpts struct {
Logg *slog.Logger
RedisDSN string
CacheType string
RedisDSN string
CacheType string
Registries []string
Watchlist []string
Blacklist []string
Chain chain.Chain
Logg *slog.Logger
}
)
@@ -24,7 +30,7 @@ func New(o CacheOpts) (Cache, error) {
var cache Cache
switch o.CacheType {
case "map":
case "internal":
cache = NewMapCache()
case "redis":
redisCache, err := NewRedisCache(redisOpts{
@@ -39,5 +45,16 @@ func New(o CacheOpts) (Cache, error) {
o.Logg.Warn("invalid cache type, using default type (map)")
}
if err := bootstrapCache(
o.Chain,
cache,
o.Registries,
o.Watchlist,
o.Blacklist,
o.Logg,
); err != nil {
return cache, err
}
return cache, nil
}