feat: Add ShardConfig to DatabaseRules proto
parent
790e5d3348
commit
98fe75c989
|
@ -118,6 +118,7 @@ impl From<DatabaseRules> for management::DatabaseRules {
|
|||
partition_template: Some(rules.partition_template.into()),
|
||||
wal_buffer_config: rules.wal_buffer_config.map(Into::into),
|
||||
mutable_buffer_config: rules.mutable_buffer_config.map(Into::into),
|
||||
shard_config: rules.shard_config.map(Into::into),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,12 +140,17 @@ impl TryFrom<management::DatabaseRules> for DatabaseRules {
|
|||
.optional("partition_template")?
|
||||
.unwrap_or_default();
|
||||
|
||||
let shard_config = proto
|
||||
.shard_config
|
||||
.optional("shard_config")
|
||||
.unwrap_or_default();
|
||||
|
||||
Ok(Self {
|
||||
name: proto.name,
|
||||
partition_template,
|
||||
wal_buffer_config,
|
||||
mutable_buffer_config,
|
||||
shard_config: None,
|
||||
shard_config,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1152,6 +1158,7 @@ mod tests {
|
|||
// These should be none as preserved on non-protobuf DatabaseRules
|
||||
assert!(back.wal_buffer_config.is_none());
|
||||
assert!(back.mutable_buffer_config.is_none());
|
||||
assert!(back.shard_config.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1542,4 +1549,20 @@ mod tests {
|
|||
assert_eq!(shard_config.ignore_errors, false);
|
||||
assert_eq!(protobuf.ignore_errors, back.ignore_errors);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_database_rules_shard_config() {
|
||||
let protobuf = management::DatabaseRules {
|
||||
name: "database".to_string(),
|
||||
shard_config: Some(management::ShardConfig {
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let rules: DatabaseRules = protobuf.try_into().unwrap();
|
||||
let back: management::DatabaseRules = rules.into();
|
||||
|
||||
assert!(back.shard_config.is_some());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package influxdata.iox.management.v1;
|
|||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "influxdata/iox/management/v1/base_types.proto";
|
||||
import "influxdata/iox/management/v1/shard.proto";
|
||||
|
||||
// `PartitionTemplate` is used to compute the partition key of each row that
|
||||
// gets written. It can consist of the table name, a column name and its value,
|
||||
|
@ -152,4 +153,7 @@ message DatabaseRules {
|
|||
|
||||
// Mutable buffer configuration for this database
|
||||
MutableBufferConfig mutable_buffer_config = 7;
|
||||
|
||||
// Shard config
|
||||
ShardConfig shard_config = 8;
|
||||
}
|
||||
|
|
|
@ -65,4 +65,3 @@ message HashRing {
|
|||
// ring of node groups. Each group holds a shard
|
||||
repeated NodeGroup node_groups = 3;
|
||||
}
|
||||
|
||||
|
|
|
@ -196,6 +196,7 @@ async fn test_create_get_database() {
|
|||
}),
|
||||
persist_after_cold_seconds: 34,
|
||||
}),
|
||||
shard_config: None,
|
||||
};
|
||||
|
||||
client
|
||||
|
|
Loading…
Reference in New Issue