Add config for durable store

This commit is contained in:
Prathamesh Musale 2023-10-12 16:38:16 +05:30
parent 8045b4cfbb
commit de0ba7fea6
4 changed files with 28 additions and 14 deletions

View File

@ -44,6 +44,8 @@ func addNitroFlags(command *cobra.Command) {
command.PersistentFlags().String("nitro-naAddress", "", "nitro naAddress")
command.PersistentFlags().String("nitro-vpaAddress", "", "nitro vpaAddress")
command.PersistentFlags().String("nitro-caAddress", "", "nitro caAddress")
command.PersistentFlags().Bool("nitro-useDurableStore", false, "nitro useDurableStore")
command.PersistentFlags().String("nitro-durableStoreFolder", "", "nitro durableStoreFolder")
// nitro flag bindings
viper.BindPFlag("nitro.pk", command.PersistentFlags().Lookup("nitro-pk"))
@ -52,4 +54,6 @@ func addNitroFlags(command *cobra.Command) {
viper.BindPFlag("nitro.naAddress", command.PersistentFlags().Lookup("nitro-naAddress"))
viper.BindPFlag("nitro.vpaAddress", command.PersistentFlags().Lookup("nitro-vpaAddress"))
viper.BindPFlag("nitro.caAddress", command.PersistentFlags().Lookup("nitro-caAddress"))
viper.BindPFlag("nitro.useDurableStore", command.PersistentFlags().Lookup("nitro-useDurableStore"))
viper.BindPFlag("nitro.durableStoreFolder", command.PersistentFlags().Lookup("nitro-durableStoreFolder"))
}

View File

@ -392,8 +392,8 @@ func init() {
func initializeNitroNode(nitroConfig *s.NitroConfig) (*nitroNode.Node, error) {
// TODO: Configure
pkString := nitroConfig.Pk
useDurableStore := true
durableStoreFolder := "./data/nitro-store"
useDurableStore := nitroConfig.UseDurableStore
durableStoreFolder := nitroConfig.DurableStoreFolder
msgPort := 3005
wsMsgPort := 5005
chainUrl := nitroConfig.ChainUrl

View File

@ -39,3 +39,5 @@
naAddress = ""
vpaAddress = ""
caAddress = ""
useDurableStore = false # NITRO_USE_DURABLE_STORE
durableStoreFolder = "" # NITRO_DURABLE_STORE_FOLDER

View File

@ -80,21 +80,25 @@ const (
DATABASE_MAX_OPEN_CONNECTIONS = "DATABASE_MAX_OPEN_CONNECTIONS"
DATABASE_MAX_CONN_LIFETIME = "DATABASE_MAX_CONN_LIFETIME"
NITRO_PK = "NITRO_PK"
NITRO_CHAIN_PK = "NITRO_CHAIN_PK"
NITRO_CHAIN_URL = "NITRO_CHAIN_URL"
NITRO_NA_ADDRESS = "NITRO_NA_ADDRESS"
NITRO_VPA_ADDRESS = "NITRO_VPA_ADDRESS"
NITRO_CA_ADDRESS = "NITRO_CA_ADDRESS"
NITRO_PK = "NITRO_PK"
NITRO_CHAIN_PK = "NITRO_CHAIN_PK"
NITRO_CHAIN_URL = "NITRO_CHAIN_URL"
NITRO_NA_ADDRESS = "NITRO_NA_ADDRESS"
NITRO_VPA_ADDRESS = "NITRO_VPA_ADDRESS"
NITRO_CA_ADDRESS = "NITRO_CA_ADDRESS"
NITRO_USE_DURABLE_STORE = "NITRO_USE_DURABLE_STORE"
NITRO_DURABLE_STORE_FOLDER = "NITRO_DURABLE_STORE_FOLDER"
)
type NitroConfig struct {
Pk string
ChainPk string
ChainUrl string
NaAddress string
VpaAddress string
CaAddress string
Pk string
ChainPk string
ChainUrl string
NaAddress string
VpaAddress string
CaAddress string
UseDurableStore bool
DurableStoreFolder string
}
// Config struct
@ -309,6 +313,8 @@ func (c *Config) loadNitroConfig() {
viper.BindEnv("nitro.naAddress", NITRO_NA_ADDRESS)
viper.BindEnv("nitro.vpaAddress", NITRO_VPA_ADDRESS)
viper.BindEnv("nitro.caAddress", NITRO_CA_ADDRESS)
viper.BindEnv("nitro.useDurableStore", NITRO_USE_DURABLE_STORE)
viper.BindEnv("nitro.durableStoreFolder", NITRO_DURABLE_STORE_FOLDER)
c.Nitro.Pk = viper.GetString("nitro.pk")
c.Nitro.ChainPk = viper.GetString("nitro.chainPk")
@ -316,6 +322,8 @@ func (c *Config) loadNitroConfig() {
c.Nitro.NaAddress = viper.GetString("nitro.naAddress")
c.Nitro.VpaAddress = viper.GetString("nitro.vpaAddress")
c.Nitro.CaAddress = viper.GetString("nitro.caAddress")
c.Nitro.UseDurableStore = viper.GetBool("nitro.useDurableStore")
c.Nitro.DurableStoreFolder = viper.GetString("nitro.durableStoreFolder")
}
func (c *Config) loadGroupCacheConfig() {