Skip to content

Commit 2c3740d

Browse files
feat(redis-enterprise): add missing fields and comprehensive documentation (#270)
- Add missing fields to License struct (activation_date, cluster_name, ram/flash shards limits) - Add missing fields to Node struct (bigstore_driver, bigstore_size, public_addr, recovery_path) - Add missing fields to ClusterInfo struct (uid, created, last_changed_time, bigstore_driver, cnm_http_port, cnm_https_port) - Add comprehensive documentation to all struct fields based on REST API docs - Add documentation to previously undocumented structs (Action, BdbGroup, etc.) - Fix License struct to handle varying field names in API responses All fields now include descriptive documentation explaining their purpose, whether they're read-only, and any constraints or deprecation notices.
1 parent cc82bd3 commit 2c3740d

File tree

6 files changed

+144
-23
lines changed

6 files changed

+144
-23
lines changed

crates/redis-enterprise/src/actions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use serde::{Deserialize, Serialize};
1111
use serde_json::Value;
1212

1313
/// Action information
14+
/// Represents an action (operation) in the cluster
1415
#[derive(Debug, Clone, Serialize, Deserialize)]
1516
pub struct Action {
1617
pub action_uid: String,
@@ -27,6 +28,7 @@ pub struct Action {
2728
}
2829

2930
/// Action handler for tracking async operations
31+
/// Handler for action-related operations
3032
pub struct ActionHandler {
3133
client: RestClient,
3234
}

crates/redis-enterprise/src/bdb_groups.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::error::Result;
1010
use serde::{Deserialize, Serialize};
1111
use serde_json::Value;
1212

13+
/// Database group information
1314
#[derive(Debug, Clone, Serialize, Deserialize)]
1415
pub struct BdbGroup {
1516
pub uid: u32,
@@ -18,6 +19,7 @@ pub struct BdbGroup {
1819
pub extra: Value,
1920
}
2021

22+
/// Handler for database group operations
2123
pub struct BdbGroupsHandler {
2224
client: RestClient,
2325
}
@@ -50,11 +52,13 @@ impl BdbGroupsHandler {
5052
}
5153
}
5254

55+
/// Request to create a new database group
5356
#[derive(Debug, Clone, Serialize, Deserialize)]
5457
pub struct CreateBdbGroupRequest {
5558
pub name: String,
5659
}
5760

61+
/// Request to update an existing database group
5862
#[derive(Debug, Clone, Serialize, Deserialize)]
5963
pub struct UpdateBdbGroupRequest {
6064
#[serde(skip_serializing_if = "Option::is_none")]

crates/redis-enterprise/src/cluster.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,56 @@ pub struct ClusterNode {
8383
/// Cluster information from the REST API
8484
#[derive(Debug, Clone, Serialize, Deserialize)]
8585
pub struct ClusterInfo {
86+
/// Cluster unique ID (read-only)
87+
pub uid: Option<u32>,
88+
89+
/// Cluster's fully qualified domain name (read-only)
8690
pub name: String,
91+
92+
/// Cluster creation date (read-only)
93+
pub created: Option<String>,
94+
95+
/// Last changed time (read-only)
96+
pub last_changed_time: Option<String>,
97+
98+
/// Software version
8799
pub version: Option<String>,
100+
101+
/// License expiration status
88102
pub license_expired: Option<bool>,
103+
104+
/// List of node UIDs in the cluster
89105
pub nodes: Option<Vec<u32>>,
106+
107+
/// List of database UIDs in the cluster
90108
pub databases: Option<Vec<u32>>,
109+
110+
/// Cluster status
91111
pub status: Option<String>,
112+
113+
/// Enables/disables node/cluster email alerts
92114
pub email_alerts: Option<bool>,
115+
116+
/// Indicates if cluster operates in rack-aware mode
93117
pub rack_aware: Option<bool>,
94118

119+
/// Storage engine for Auto Tiering ('speedb' or 'rocksdb')
120+
pub bigstore_driver: Option<String>,
121+
122+
/// API HTTP listening port (range: 1024-65535)
123+
pub cnm_http_port: Option<u16>,
124+
125+
/// API HTTPS listening port (range: 1024-65535)
126+
pub cnm_https_port: Option<u16>,
127+
95128
// Stats
129+
/// Total memory available in the cluster
96130
pub total_memory: Option<u64>,
131+
132+
/// Total memory used in the cluster
97133
pub used_memory: Option<u64>,
134+
135+
/// Total number of shards in the cluster
98136
pub total_shards: Option<u32>,
99137

100138
#[serde(flatten)]

crates/redis-enterprise/src/license.rs

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,66 @@ use typed_builder::TypedBuilder;
1414
/// License information
1515
#[derive(Debug, Clone, Serialize, Deserialize)]
1616
pub struct License {
17+
/// License key string
1718
pub license_key: String,
18-
pub type_: String,
19+
20+
/// Key field (some endpoints may return this instead of license_key)
21+
#[serde(skip_serializing_if = "Option::is_none")]
22+
pub key: Option<String>,
23+
24+
/// License string
25+
#[serde(skip_serializing_if = "Option::is_none")]
26+
pub license: Option<String>,
27+
28+
/// License type
29+
pub type_: Option<String>,
30+
31+
/// Mark license expired or not
1932
pub expired: bool,
33+
34+
/// License activation date
35+
#[serde(skip_serializing_if = "Option::is_none")]
36+
pub activation_date: Option<String>,
37+
38+
/// License expiration date
2039
#[serde(skip_serializing_if = "Option::is_none")]
2140
pub expiration_date: Option<String>,
41+
42+
/// The cluster name as appears in the license
43+
#[serde(skip_serializing_if = "Option::is_none")]
44+
pub cluster_name: Option<String>,
45+
46+
/// Owner of license
47+
#[serde(skip_serializing_if = "Option::is_none")]
48+
pub owner: Option<String>,
49+
50+
/// Shards limit
2251
#[serde(skip_serializing_if = "Option::is_none")]
2352
pub shards_limit: Option<u32>,
53+
54+
/// Amount of RAM shards in use
55+
#[serde(skip_serializing_if = "Option::is_none")]
56+
pub ram_shards_in_use: Option<u32>,
57+
58+
/// Amount of RAM shards allowed
59+
#[serde(skip_serializing_if = "Option::is_none")]
60+
pub ram_shards_limit: Option<u32>,
61+
62+
/// Amount of flash shards in use
63+
#[serde(skip_serializing_if = "Option::is_none")]
64+
pub flash_shards_in_use: Option<u32>,
65+
66+
/// Amount of flash shards allowed
67+
#[serde(skip_serializing_if = "Option::is_none")]
68+
pub flash_shards_limit: Option<u32>,
69+
70+
/// Node limit (deprecated in favor of shards_limit)
2471
#[serde(skip_serializing_if = "Option::is_none")]
2572
pub node_limit: Option<u32>,
73+
74+
/// List of features supported by license
2675
#[serde(skip_serializing_if = "Option::is_none")]
2776
pub features: Option<Vec<String>>,
28-
#[serde(skip_serializing_if = "Option::is_none")]
29-
pub owner: Option<String>,
3077

3178
#[serde(flatten)]
3279
pub extra: Value,

crates/redis-enterprise/src/nodes.rs

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,73 +26,103 @@ pub struct NodeActionResponse {
2626
/// Node information
2727
#[derive(Debug, Clone, Serialize, Deserialize)]
2828
pub struct Node {
29+
/// Cluster unique ID of node (read-only)
2930
pub uid: u32,
3031

31-
/// IP address of the node (renamed from 'address' to match API)
32+
/// Internal IP address of node
3233
#[serde(rename = "addr")]
3334
pub addr: Option<String>,
3435

36+
/// Node status (read-only)
3537
pub status: String,
3638

37-
/// Whether node accepts new shards
39+
/// Node accepts new shards if true
3840
pub accept_servers: Option<bool>,
3941

40-
/// System architecture (e.g., "aarch64", "x86_64")
42+
/// Hardware architecture (read-only)
4143
pub architecture: Option<String>,
4244

43-
/// CPU cores (renamed from 'cpu_cores' to match API)
45+
/// Total number of CPU cores (read-only)
4446
#[serde(rename = "cores")]
4547
pub cores: Option<u32>,
4648

47-
/// External IP addresses
49+
/// External IP addresses of node
4850
pub external_addr: Option<Vec<String>>,
4951

5052
/// Total memory in bytes
5153
pub total_memory: Option<u64>,
5254

53-
/// OS version information
55+
/// Installed OS version (read-only)
5456
pub os_version: Option<String>,
57+
/// Operating system name (read-only)
5558
pub os_name: Option<String>,
59+
/// Operating system family (read-only)
5660
pub os_family: Option<String>,
61+
/// Full version number (read-only)
5762
pub os_semantic_version: Option<String>,
5863

59-
/// Storage sizes (API returns f64, not u64)
64+
/// Ephemeral storage size in bytes (read-only)
6065
pub ephemeral_storage_size: Option<f64>,
66+
/// Persistent storage size in bytes (read-only)
6167
pub persistent_storage_size: Option<f64>,
6268

63-
/// Storage paths
69+
/// Ephemeral storage path (read-only)
6470
pub ephemeral_storage_path: Option<String>,
71+
/// Persistent storage path (read-only)
6572
pub persistent_storage_path: Option<String>,
73+
/// Flash storage path (read-only)
6674
pub bigredis_storage_path: Option<String>,
6775

68-
/// Rack configuration
76+
/// Rack ID where node is installed
6977
pub rack_id: Option<String>,
78+
/// Second rack ID where node is installed
7079
pub second_rack_id: Option<String>,
7180

72-
/// Shard information
81+
/// Number of shards on the node (read-only)
7382
pub shard_count: Option<u32>,
83+
/// Cluster unique IDs of all node shards
7484
pub shard_list: Option<Vec<u32>>,
85+
/// RAM shard count
7586
pub ram_shard_count: Option<u32>,
87+
/// Flash shard count
7688
pub flash_shard_count: Option<u32>,
7789

78-
/// Features and capabilities
90+
/// Flash storage enabled for Auto Tiering databases
7991
pub bigstore_enabled: Option<bool>,
92+
/// FIPS mode enabled
8093
pub fips_enabled: Option<bool>,
94+
/// Use internal IPv6
8195
pub use_internal_ipv6: Option<bool>,
8296

83-
/// Limits and settings
97+
/// Maximum number of listeners on the node
8498
pub max_listeners: Option<u32>,
99+
/// Maximum number of shards on the node
85100
pub max_redis_servers: Option<u32>,
101+
/// Maximum background processes forked from shards
86102
pub max_redis_forks: Option<i32>,
103+
/// Maximum simultaneous replica full syncs
87104
pub max_slave_full_syncs: Option<i32>,
88105

89-
/// Runtime information
106+
/// Node uptime in seconds
90107
pub uptime: Option<u64>,
108+
/// Installed Redis Enterprise cluster software version (read-only)
91109
pub software_version: Option<String>,
92110

93-
/// Supported Redis versions
111+
/// Supported database versions
94112
pub supported_database_versions: Option<Vec<Value>>,
95113

114+
/// Bigstore driver name (deprecated)
115+
pub bigstore_driver: Option<String>,
116+
117+
/// Storage size of bigstore storage (read-only)
118+
pub bigstore_size: Option<u64>,
119+
120+
/// Public IP address (deprecated)
121+
pub public_addr: Option<String>,
122+
123+
/// Recovery files path
124+
pub recovery_path: Option<String>,
125+
96126
/// Capture any additional fields not explicitly defined
97127
#[serde(flatten)]
98128
pub extra: Value,

crates/redis-enterprise/tests/license_tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async fn test_license_get() {
7979
assert!(result.is_ok());
8080
let license = result.unwrap();
8181
assert_eq!(license.license_key, "lic-123-456-789");
82-
assert_eq!(license.type_, "production");
82+
assert_eq!(license.type_, Some("production".to_string()));
8383
assert!(!license.expired);
8484
assert_eq!(
8585
license.expiration_date,
@@ -122,7 +122,7 @@ async fn test_license_get_expired() {
122122
assert!(result.is_ok());
123123
let license = result.unwrap();
124124
assert_eq!(license.license_key, "lic-expired-123");
125-
assert_eq!(license.type_, "trial");
125+
assert_eq!(license.type_, Some("trial".to_string()));
126126
assert!(license.expired);
127127
assert_eq!(
128128
license.expiration_date,
@@ -156,7 +156,7 @@ async fn test_license_get_minimal() {
156156
assert!(result.is_ok());
157157
let license = result.unwrap();
158158
assert_eq!(license.license_key, "lic-minimal-789");
159-
assert_eq!(license.type_, "dev");
159+
assert_eq!(license.type_, Some("dev".to_string()));
160160
assert!(!license.expired);
161161
assert!(license.expiration_date.is_none());
162162
assert!(license.shards_limit.is_none());
@@ -203,7 +203,7 @@ async fn test_license_update() {
203203
assert!(result.is_ok());
204204
let license = result.unwrap();
205205
assert_eq!(license.license_key, "new-license-key-12345");
206-
assert_eq!(license.type_, "production");
206+
assert_eq!(license.type_, Some("production".to_string()));
207207
assert!(!license.expired);
208208
assert_eq!(license.shards_limit, Some(200));
209209
assert_eq!(license.node_limit, Some(20));
@@ -323,7 +323,7 @@ async fn test_license_validate_valid() {
323323
assert!(result.is_ok());
324324
let license = result.unwrap();
325325
assert_eq!(license.license_key, "valid-license-to-validate");
326-
assert_eq!(license.type_, "production");
326+
assert_eq!(license.type_, Some("production".to_string()));
327327
assert!(!license.expired);
328328
assert_eq!(license.shards_limit, Some(50));
329329
assert_eq!(license.node_limit, Some(5));
@@ -394,7 +394,7 @@ async fn test_license_cluster_license() {
394394
assert!(result.is_ok());
395395
let license = result.unwrap();
396396
assert_eq!(license.license_key, "cluster-license-789");
397-
assert_eq!(license.type_, "enterprise");
397+
assert_eq!(license.type_, Some("enterprise".to_string()));
398398
assert!(!license.expired);
399399
assert_eq!(license.shards_limit, Some(1000));
400400
assert_eq!(license.node_limit, Some(100));

0 commit comments

Comments
 (0)