Skip to content

Commit

Permalink
Add auto reduce allocation to healthy API (#469)
Browse files Browse the repository at this point in the history
* Add expiration to channel API

* Add auto reduce allocation to healthy

* remove ara from metadata
  • Loading branch information
nz-neooo authored Jul 23, 2024
1 parent 3975e19 commit 3b46469
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/indexer-proxy/proxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subql-indexer-proxy"
version = "2.4.1"
version = "2.4.2"
edition = "2021"

[dependencies]
Expand Down
6 changes: 5 additions & 1 deletion apps/indexer-proxy/proxy/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use tdn::prelude::PeerKey;
use tokio::sync::RwLock;

use crate::cli::COMMAND;
use crate::metadata::auto_reduce_allocation_enabled;
use crate::metrics::{get_services_version, get_status};
use crate::p2p::{start_network, stop_network};

Expand Down Expand Up @@ -147,12 +148,15 @@ pub async fn indexer_healthy() -> Value {
let proxy_version = decode_proxy_version(u32::from_le_bytes(p_v));
let coordinator_version = decode_proxy_version(u32::from_le_bytes(c_v));

let arae = auto_reduce_allocation_enabled().await;

json!({
"indexer": format!("{:?}", indexer),
"controller": format!("{:?}", controller),
"uptime": uptime,
"proxyVersion": proxy_version,
"coordinatorVersion": coordinator_version,
"os": os
"os": os,
"autoReduceAllocation": arae
})
}
5 changes: 1 addition & 4 deletions apps/indexer-proxy/proxy/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ use crate::account::ACCOUNT;
use crate::cli::{redis, COMMAND};
use crate::graphql::project_mainfest;
use crate::metadata::{
auto_reduce_allocation_enabled, rpc_evm_metadata, rpc_substrate_metadata, subgraph_metadata,
subquery_metadata,
rpc_evm_metadata, rpc_substrate_metadata, subgraph_metadata, subquery_metadata,
};
use crate::metrics::{add_metrics_query, update_metrics_projects, MetricsNetwork, MetricsQuery};
use crate::p2p::send;
Expand Down Expand Up @@ -344,7 +343,6 @@ impl Project {
.await
.map_err(|_| Error::InvalidSignature(1041))?;

let arae = auto_reduce_allocation_enabled().await;
let common = json!({
"indexer": format!("{:?}", indexer),
"controller": format!("{:?}", controller_address),
Expand All @@ -353,7 +351,6 @@ impl Project {
"rateLimit": self.rate_limit.unwrap_or(1000),
"dbSize": self.db_size,
"signature": sign.to_string(),
"autoReduceAllocation": arae,
});

merge_json(&mut metadata, &common);
Expand Down
1 change: 1 addition & 0 deletions apps/indexer-proxy/proxy/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ async fn payg_state(Path(channel): Path<String>) -> Result<Json<Value>, Error> {
"total": state.total.to_string(),
"spent": state.spent.to_string(),
"remote": state.remote.to_string(),
"expired_at": state.expiration,
"conflict_start": state.conflict_start,
"conflict_times": state.conflict_times
})))
Expand Down

0 comments on commit 3b46469

Please sign in to comment.