Skip to content

Commit

Permalink
Serve some basic config info at /info. (#14842)
Browse files Browse the repository at this point in the history
  • Loading branch information
grao1991 authored Oct 14, 2024
1 parent ee1791a commit 2a0e7d6
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
22 changes: 22 additions & 0 deletions api/doc/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1900,6 +1900,28 @@
"operationId": "spec"
}
},
"/info": {
"get": {
"tags": [
"General"
],
"summary": "Show some basic info of the node.",
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {}
}
}
}
}
},
"operationId": "info"
}
},
"/-/healthy": {
"get": {
"tags": [
Expand Down
14 changes: 14 additions & 0 deletions api/doc/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,20 @@ paths:
schema:
type: string
operationId: spec
/info:
get:
tags:
- General
summary: Show some basic info of the node.
responses:
'200':
description: ''
content:
application/json:
schema:
type: object
additionalProperties: {}
operationId: info
/-/healthy:
get:
tags:
Expand Down
57 changes: 56 additions & 1 deletion api/src/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ use crate::{
};
use anyhow::Context as AnyhowContext;
use aptos_api_types::AptosErrorCode;
use poem_openapi::{param::Query, payload::Html, Object, OpenApi};
use poem_openapi::{
param::Query,
payload::{Html, Json},
Object, OpenApi,
};
use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
ops::Sub,
sync::Arc,
time::{Duration, SystemTime, UNIX_EPOCH},
Expand Down Expand Up @@ -60,6 +65,56 @@ impl BasicApi {
Html(OPEN_API_HTML.to_string())
}

/// Show some basic info of the node.
#[oai(
path = "/info",
method = "get",
operation_id = "info",
tag = "ApiTags::General"
)]
async fn info(&self) -> Json<HashMap<String, serde_json::Value>> {
let mut info = HashMap::new();
info.insert(
"bootstrapping_mode".to_string(),
serde_json::to_value(
self.context
.node_config
.state_sync
.state_sync_driver
.bootstrapping_mode,
)
.unwrap(),
);
info.insert(
"continuous_syncing_mode".to_string(),
serde_json::to_value(
self.context
.node_config
.state_sync
.state_sync_driver
.continuous_syncing_mode,
)
.unwrap(),
);
info.insert(
"new_storage_format".to_string(),
serde_json::to_value(
self.context
.node_config
.storage
.rocksdb_configs
.enable_storage_sharding,
)
.unwrap(),
);
info.insert(
"internal_indexer_config".to_string(),
serde_json::to_value(&self.context.node_config.indexer_db_config).unwrap(),
);

Json(info)
}

/// Check basic node health
///
/// By default this endpoint just checks that it can get the latest ledger
Expand Down

0 comments on commit 2a0e7d6

Please sign in to comment.