Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ restate-bifrost = { workspace = true, features = ["local-loglet", "replicated-lo
restate-core = { workspace = true }
restate-errors = { workspace = true }
restate-ingestion-client = { workspace = true }
restate-metadata-server-grpc = { workspace = true, features = ["grpc-client"] }
restate-metadata-store = { workspace = true }
restate-metadata-providers = { workspace = true }
restate-service-client = { workspace = true }
Expand Down
76 changes: 76 additions & 0 deletions crates/admin/src/rest_api/internal_cluster_common.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright (c) 2023 - 2026 Restate Software, Inc., Restate GmbH.
// All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use serde::Serialize;

use restate_types::logs::metadata::ProviderConfiguration;
use restate_types::partition_table::PartitionReplication;
use restate_types::replication::ReplicationProperty;

#[derive(Debug, Clone, Serialize)]
pub(super) struct LogsProviderView {
/// Provider kind (in-memory, local, or replicated).
pub kind: String,
/// Replication property if provider kind is replicated.
pub replication_property: Option<ReplicationProperty>,
/// Target nodeset size if provider kind is replicated.
pub target_nodeset_size: Option<u32>,
}

#[derive(Debug, Clone, Serialize)]
pub(super) struct PartitionReplicationView {
/// Replication mode.
pub mode: PartitionReplicationMode,
/// Required copies per location scope when mode is `limit`.
#[serde(skip_serializing_if = "Option::is_none")]
pub copies: Option<ReplicationProperty>,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "snake_case")]
pub(super) enum PartitionReplicationMode {
Everywhere,
Limit,
}

pub(super) fn logs_provider_view(provider: ProviderConfiguration) -> LogsProviderView {
match provider {
ProviderConfiguration::InMemory => LogsProviderView {
kind: "in-memory".to_owned(),
replication_property: None,
target_nodeset_size: None,
},
ProviderConfiguration::Local => LogsProviderView {
kind: "local".to_owned(),
replication_property: None,
target_nodeset_size: None,
},
ProviderConfiguration::Replicated(config) => LogsProviderView {
kind: "replicated".to_owned(),
replication_property: Some(config.replication_property.clone()),
target_nodeset_size: Some(config.target_nodeset_size.as_u32()),
},
}
}

pub(super) fn partition_replication_view(
partition_replication: &PartitionReplication,
) -> PartitionReplicationView {
match partition_replication {
PartitionReplication::Everywhere => PartitionReplicationView {
mode: PartitionReplicationMode::Everywhere,
copies: None,
},
PartitionReplication::Limit(replication_property) => PartitionReplicationView {
mode: PartitionReplicationMode::Limit,
copies: Some(replication_property.clone()),
},
}
}
41 changes: 41 additions & 0 deletions crates/admin/src/rest_api/internal_cluster_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) 2023 - 2026 Restate Software, Inc., Restate GmbH.
// All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use axum::Json;
use serde::Serialize;

use restate_core::Metadata;

use super::internal_cluster_common::{
LogsProviderView, PartitionReplicationView, logs_provider_view, partition_replication_view,
};

#[derive(Debug, Clone, Serialize)]
pub struct InternalClusterConfigResponse {
/// Total number of partitions configured for the cluster.
pub num_partitions: u32,
/// Partition replication strategy.
pub partition_replication: PartitionReplicationView,
/// Default provider used when creating new logs.
pub logs_provider: LogsProviderView,
}

pub async fn get_internal_cluster_config() -> Json<InternalClusterConfigResponse> {
Json(Metadata::with_current(|metadata| {
let logs = metadata.logs_ref();
let partition_table = metadata.partition_table_ref();

InternalClusterConfigResponse {
num_partitions: u32::from(partition_table.num_partitions()),
partition_replication: partition_replication_view(partition_table.replication()),
logs_provider: logs_provider_view(logs.configuration().default_provider.clone()),
}
}))
}
Loading
Loading