1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-16 04:24:56 +02:00

cmd/thalos/main.go: use new cache struct and abi manager.

This commit is contained in:
Henrik Hautakoski 2023-11-01 21:25:54 +01:00
parent 424ae2fc40
commit 2acae14ff8

View file

@ -21,8 +21,10 @@ import (
api_redis "github.com/eosswedenorg/thalos/api/redis"
"github.com/eosswedenorg/thalos/app"
"github.com/eosswedenorg/thalos/app/abi"
. "github.com/eosswedenorg/thalos/app/cache"
"github.com/eosswedenorg/thalos/app/config"
. "github.com/eosswedenorg/thalos/app/log"
redis_cache "github.com/go-redis/cache/v9"
"github.com/nikoksr/notify"
"github.com/nikoksr/notify/service/telegram"
"github.com/pborman/getopt/v2"
@ -44,6 +46,10 @@ var VersionString string = "dev"
var exit chan bool
var cache *Cache
var cacheStore Store
func readerLoop(processor *app.ShipProcessor) {
running = true
recon_cnt := 0
@ -171,6 +177,11 @@ func LogLevels() []string {
return list
}
func initAbiManger(api *eos.API, chain_id string) *abi.AbiManager {
cache := NewCache("thalos::cache::abi::"+chain_id, cacheStore)
return abi.NewAbiManager(cache, api)
}
func main() {
var err error
var chainInfo *eos.InfoResp
@ -281,6 +292,16 @@ func main() {
return
}
// Setup cache storage
cacheStore = NewRedisStore(&redis_cache.Options{
Redis: rdb,
// Cache 10k keys for 10 minutes.
LocalCache: redis_cache.NewTinyLFU(10000, 10*time.Minute),
})
// Setup general cache
cache = NewCache("thalos::cache::instance::"+conf.Name, cacheStore)
log.WithField("api", conf.Api).Info("Get chain info from api")
eosClient := eos.New(conf.Api)
chainInfo, err = eosClient.GetInfo(context.Background())
@ -318,7 +339,7 @@ func main() {
Prefix: conf.Redis.Prefix,
ChainID: chain_id,
}),
abi.NewAbiManager(rdb, eosClient, chain_id),
initAbiManger(eosClient, chain_id),
codec,
)