Skip to content

Commit

Permalink
(NOBIDS) move ratelimit-updater to fdu (#2924)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybrush authored Jul 31, 2024
1 parent db2fbe6 commit 14e16d4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 1 addition & 4 deletions cmd/misc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/gobitfly/eth2-beaconchain-explorer/cmd/misc/commands"
"github.com/gobitfly/eth2-beaconchain-explorer/db"
"github.com/gobitfly/eth2-beaconchain-explorer/exporter"
"github.com/gobitfly/eth2-beaconchain-explorer/ratelimit"
"github.com/gobitfly/eth2-beaconchain-explorer/rpc"
"github.com/gobitfly/eth2-beaconchain-explorer/services"
"github.com/gobitfly/eth2-beaconchain-explorer/types"
Expand Down Expand Up @@ -76,7 +75,7 @@ func main() {
statsPartitionCommand := commands.StatsMigratorCommand{}

configPath := flag.String("config", "config/default.config.yml", "Path to the config file")
flag.StringVar(&opts.Command, "command", "", "command to run, available: updateAPIKey, applyDbSchema, initBigtableSchema, epoch-export, debug-rewards, debug-blocks, clear-bigtable, index-old-eth1-blocks, update-aggregation-bits, historic-prices-export, index-missing-blocks, export-epoch-missed-slots, migrate-last-attestation-slot-bigtable, export-genesis-validators, update-block-finalization-sequentially, nameValidatorsByRanges, export-stats-totals, export-sync-committee-periods, export-sync-committee-validator-stats, partition-validator-stats, migrate-app-purchases, update-ratelimits, disable-user-per-email")
flag.StringVar(&opts.Command, "command", "", "command to run, available: updateAPIKey, applyDbSchema, initBigtableSchema, epoch-export, debug-rewards, debug-blocks, clear-bigtable, index-old-eth1-blocks, update-aggregation-bits, historic-prices-export, index-missing-blocks, export-epoch-missed-slots, migrate-last-attestation-slot-bigtable, export-genesis-validators, update-block-finalization-sequentially, nameValidatorsByRanges, export-stats-totals, export-sync-committee-periods, export-sync-committee-validator-stats, partition-validator-stats, migrate-app-purchases, disable-user-per-email")
flag.Uint64Var(&opts.StartEpoch, "start-epoch", 0, "start epoch")
flag.Uint64Var(&opts.EndEpoch, "end-epoch", 0, "end epoch")
flag.Uint64Var(&opts.User, "user", 0, "user id")
Expand Down Expand Up @@ -435,8 +434,6 @@ func main() {
err = fixEns(erigonClient)
case "fix-ens-addresses":
err = fixEnsAddresses(erigonClient)
case "update-ratelimits":
ratelimit.DBUpdater()
case "disable-user-per-email":
err = disableUserPerEmail()
case "fix-epochs":
Expand Down
2 changes: 1 addition & 1 deletion ratelimit/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ func DBGetCurrentApiProducts() ([]*ApiProduct, error) {
}

func DBUpdater() {
iv := utils.Config.Frontend.RatelimitUpdateInterval
iv := utils.Config.RatelimitUpdater.UpdateInterval
if iv < time.Second {
logger.Warnf("updateInterval is below 1s, setting to 60s")
iv = time.Second * 60
Expand Down
5 changes: 5 additions & 0 deletions services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/gobitfly/eth2-beaconchain-explorer/db"
ethclients "github.com/gobitfly/eth2-beaconchain-explorer/ethClients"
"github.com/gobitfly/eth2-beaconchain-explorer/price"
"github.com/gobitfly/eth2-beaconchain-explorer/ratelimit"
"github.com/gobitfly/eth2-beaconchain-explorer/types"
"github.com/gobitfly/eth2-beaconchain-explorer/utils"

Expand Down Expand Up @@ -86,6 +87,10 @@ func Init() {
ready.Add(1)
go latestExportedStatisticDayUpdater(ready)

if utils.Config.RatelimitUpdater.Enabled {
go ratelimit.DBUpdater()
}

ready.Wait()
}

Expand Down
4 changes: 4 additions & 0 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ type Config struct {
MachineEventFirstRatioThreshold float64 `yaml:"machineEventFirstRatioThreshold" envconfig:"MACHINE_EVENT_FIRST_RATIO_THRESHOLD"`
MachineEventSecondRatioThreshold float64 `yaml:"machineEventSecondRatioThreshold" envconfig:"MACHINE_EVENT_SECOND_RATIO_THRESHOLD"`
} `yaml:"notifications"`
RatelimitUpdater struct {
Enabled bool `yaml:"enabled" envconfig:"RATELIMIT_UPDATER_ENABLED"`
UpdateInterval time.Duration `yaml:"updateInterval" envconfig:"RATELIMIT_UPDATER_UPDATE_INTERVAL"`
}
SSVExporter struct {
Enabled bool `yaml:"enabled" envconfig:"SSV_EXPORTER_ENABLED"`
Address string `yaml:"address" envconfig:"SSV_EXPORTER_ADDRESS"`
Expand Down

0 comments on commit 14e16d4

Please sign in to comment.