Skip to content

Commit fb2b702

Browse files
authored
Merge pull request #415 from near/develop
fix parse config.toml (#414)
2 parents b5fe030 + eb57f24 commit fb2b702

File tree

5 files changed

+11
-16
lines changed

5 files changed

+11
-16
lines changed

configuration/src/configs/general.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct GeneralRpcServerConfig {
2121
pub block_cache_size: f64,
2222
pub shadow_data_consistency_rate: f64,
2323
pub prefetch_state_size_limit: u64,
24+
pub tx_details_storage_provider: StorageProvider,
2425
}
2526

2627
#[derive(Debug, Clone)]
@@ -68,7 +69,7 @@ pub struct CommonGeneralConfig {
6869
pub tx_indexer: CommonGeneralTxIndexerConfig,
6970
#[serde(default)]
7071
pub state_indexer: CommonGeneralStateIndexerConfig,
71-
#[serde(default)]
72+
#[serde(deserialize_with = "deserialize_data_or_env")]
7273
pub tx_details_storage_provider: StorageProvider,
7374
}
7475

@@ -194,8 +195,6 @@ pub struct CommonGeneralTxIndexerConfig {
194195
pub indexer_id: Option<String>,
195196
#[serde(deserialize_with = "deserialize_optional_data_or_env", default)]
196197
pub metrics_server_port: Option<u16>,
197-
#[serde(deserialize_with = "deserialize_optional_data_or_env", default)]
198-
pub tx_details_storage_provider: Option<StorageProvider>,
199198
}
200199

201200
impl CommonGeneralTxIndexerConfig {
@@ -213,7 +212,6 @@ impl Default for CommonGeneralTxIndexerConfig {
213212
Self {
214213
indexer_id: Some(Self::default_indexer_id()),
215214
metrics_server_port: Some(Self::default_metrics_server_port()),
216-
tx_details_storage_provider: Some(StorageProvider::Postgres),
217215
}
218216
}
219217
}
@@ -292,6 +290,7 @@ impl From<CommonGeneralConfig> for GeneralRpcServerConfig {
292290
.rpc_server
293291
.prefetch_state_size_limit
294292
.unwrap_or_else(CommonGeneralRpcServerConfig::default_prefetch_state_size_limit),
293+
tx_details_storage_provider: common_config.tx_details_storage_provider,
295294
}
296295
}
297296
}

configuration/src/configs/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,11 @@ pub struct RpcServerConfig {
120120
pub lake_config: lake::LakeConfig,
121121
pub database: database::DatabaseConfig,
122122
pub tx_details_storage: tx_details_storage::TxDetailsStorageConfig,
123-
pub tx_details_storage_provider: general::StorageProvider,
124123
}
125124

126125
impl Config for RpcServerConfig {
127126
fn from_common_config(common_config: CommonConfig) -> Self {
128127
Self {
129-
tx_details_storage_provider: common_config.general.tx_details_storage_provider.clone(),
130128
general: common_config.general.into(),
131129
lake_config: common_config.lake_config.into(),
132130
database: database::DatabaseConfig::from(common_config.database).to_read_only(),
@@ -144,7 +142,6 @@ pub struct TxIndexerConfig {
144142
pub lake_config: lake::LakeConfig,
145143
pub database: database::DatabaseConfig,
146144
pub tx_details_storage: tx_details_storage::TxDetailsStorageConfig,
147-
pub tx_details_storage_provider: general::StorageProvider,
148145
}
149146

150147
impl TxIndexerConfig {
@@ -159,7 +156,6 @@ impl TxIndexerConfig {
159156
impl Config for TxIndexerConfig {
160157
fn from_common_config(common_config: CommonConfig) -> Self {
161158
Self {
162-
tx_details_storage_provider: common_config.general.tx_details_storage_provider.clone(),
163159
general: common_config.general.into(),
164160
rightsizing: common_config.rightsizing.into(),
165161
lake_config: common_config.lake_config.into(),

configuration/src/default_env_configs.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ rpc_auth_token = "${RPC_AUTH_TOKEN}"
3030
## Default value is redis://127.0.0.1/
3131
redis_url = "${REDIS_URL}"
3232
33+
## Transaction details storage provider
34+
## Options: "scylladb", "postgres"
35+
## Default value is "postgres"
36+
tx_details_storage_provider = "${TX_DETAILS_STORAGE_PROVIDER}"
37+
3338
### Rpc server general configuration
3439
[general.rpc_server]
3540
@@ -78,11 +83,6 @@ indexer_id = "${TX_INDEXER_ID}"
7883
## By default it 8080 for tx-indexer and 8081 for state-indexer
7984
metrics_server_port = "${TX_SERVER_PORT}"
8085
81-
## Transaction details storage provider
82-
## Options: "scylla", "postgres"
83-
## Default value is "postgres"
84-
#tx_details_storage_provider = "${TX_DETAILS_STORAGE_PROVIDER}"
85-
8686
### State indexer general configuration
8787
[general.state_indexer]
8888

rpc-server/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl ServerContext {
141141
.await?;
142142

143143
let tx_details_storage: std::sync::Arc<dyn tx_details_storage::Storage + Send + Sync> =
144-
match rpc_server_config.tx_details_storage_provider {
144+
match rpc_server_config.general.tx_details_storage_provider {
145145
configuration::StorageProvider::ScyllaDb => {
146146
let scylla_session = rpc_server_config
147147
.tx_details_storage

tx-indexer/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ async fn main() -> anyhow::Result<()> {
3030
.lake_client(indexer_config.general.chain_id.clone())
3131
.await?;
3232

33-
tracing::info!(target: INDEXER, "Instantiating the tx_details storage client with {:?} provider...", &indexer_config.tx_details_storage_provider);
33+
tracing::info!(target: INDEXER, "Instantiating the tx_details storage client with {:?} provider...", &indexer_config.general.tx_details_storage_provider);
3434
let tx_details_storage: std::sync::Arc<dyn tx_details_storage::Storage + Send + Sync> =
35-
match indexer_config.tx_details_storage_provider {
35+
match indexer_config.general.tx_details_storage_provider {
3636
configuration::StorageProvider::ScyllaDb => {
3737
let scylla_session = indexer_config
3838
.tx_details_storage

0 commit comments

Comments
 (0)