forked from asymmetric-research/solana-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request asymmetric-research#45 from asymmetric-research/mo…
…re-config More config updates
- Loading branch information
Showing
5 changed files
with
254 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"time" | ||
) | ||
|
||
type ( | ||
arrayFlags []string | ||
|
||
ExporterConfig struct { | ||
HttpTimeout time.Duration | ||
RpcUrl string | ||
ListenAddress string | ||
NodeKeys []string | ||
BalanceAddresses []string | ||
ComprehensiveSlotTracking bool | ||
} | ||
) | ||
|
||
func (i *arrayFlags) String() string { | ||
return fmt.Sprint(*i) | ||
} | ||
|
||
func (i *arrayFlags) Set(value string) error { | ||
*i = append(*i, value) | ||
return nil | ||
} | ||
|
||
func NewExporterConfig( | ||
httpTimeout int, | ||
rpcUrl string, | ||
listenAddress string, | ||
nodeKeys []string, | ||
balanceAddresses []string, | ||
comprehensiveSlotTracking bool, | ||
) *ExporterConfig { | ||
return &ExporterConfig{ | ||
HttpTimeout: time.Duration(httpTimeout) * time.Second, | ||
RpcUrl: rpcUrl, | ||
ListenAddress: listenAddress, | ||
NodeKeys: nodeKeys, | ||
BalanceAddresses: balanceAddresses, | ||
ComprehensiveSlotTracking: comprehensiveSlotTracking, | ||
} | ||
} | ||
|
||
func NewExporterConfigFromCLI() *ExporterConfig { | ||
var ( | ||
httpTimeout int | ||
rpcUrl string | ||
listenAddress string | ||
nodekeys arrayFlags | ||
balanceAddresses arrayFlags | ||
comprehensiveSlotTracking bool | ||
) | ||
flag.IntVar( | ||
&httpTimeout, | ||
"http-timeout", | ||
60, | ||
"HTTP timeout to use, in seconds.", | ||
) | ||
flag.StringVar( | ||
&rpcUrl, | ||
"rpc-url", | ||
"http://localhost:8899", | ||
"Solana RPC URL (including protocol and path), "+ | ||
"e.g., 'http://localhost:8899' or 'https://api.mainnet-beta.solana.com'", | ||
) | ||
flag.StringVar( | ||
&listenAddress, | ||
"listen-address", | ||
":8080", | ||
"Listen address", | ||
) | ||
flag.Var( | ||
&nodekeys, | ||
"nodekey", | ||
"Solana nodekey (identity account) representing validator to monitor - can set multiple times.", | ||
) | ||
flag.Var( | ||
&balanceAddresses, | ||
"balance-address", | ||
"Address to monitor SOL balances for, in addition to the identity and vote accounts of the "+ | ||
"provided nodekeys - can be set multiple times.", | ||
) | ||
flag.BoolVar( | ||
&comprehensiveSlotTracking, | ||
"comprehensive-slot-tracking", | ||
false, | ||
"Set this flag to track solana_leader_slots_by_epoch for ALL validators. "+ | ||
"Warning: this will lead to potentially thousands of new Prometheus metrics being created every epoch.", | ||
) | ||
flag.Parse() | ||
|
||
return NewExporterConfig(httpTimeout, rpcUrl, listenAddress, nodekeys, balanceAddresses, comprehensiveSlotTracking) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.