Skip to content

Commit

Permalink
add other fields as flags
Browse files Browse the repository at this point in the history
  • Loading branch information
technicallyty committed Jul 25, 2024
1 parent 8280da0 commit f28d1f5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/slinky/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ var (
flagMetricsPrometheusAddress = "metrics-prometheus-address"
flagHost = "host"
flagPort = "port"
flagUpdateInterval = "update-interval"
flagMaxPriceAge = "max-price-age"

// flag-bound values
oracleCfgPath string
Expand Down Expand Up @@ -205,12 +207,24 @@ func init() {
cmdconfig.DefaultPort,
"The port the Oracle will serve from",
)
rootCmd.Flags().Int(
flagUpdateInterval,
cmdconfig.DefaultUpdateInterval,
"The interval at which the oracle will fetch prices from providers",
)
rootCmd.Flags().Duration(
flagMaxPriceAge,
cmdconfig.DefaultMaxPriceAge,
"Maximum age of a price that the oracle will consider valid",
)
// bind them to viper.
err := errors.Join(
viper.BindPFlag("host", rootCmd.Flags().Lookup(flagHost)),
viper.BindPFlag("port", rootCmd.Flags().Lookup(flagPort)),
viper.BindPFlag("metrics.enabled", rootCmd.Flags().Lookup(flagMetricsEnabled)),
viper.BindPFlag("metrics.prometheusServerAddress", rootCmd.Flags().Lookup(flagMetricsPrometheusAddress)),
viper.BindPFlag("maxPriceAge", rootCmd.Flags().Lookup(flagMaxPriceAge)),
viper.BindPFlag("updateInterval", rootCmd.Flags().Lookup(flagUpdateInterval)),
)
if err != nil {
panic(fmt.Sprintf("failed to bind flags: %v", err))
Expand Down

0 comments on commit f28d1f5

Please sign in to comment.