Send partition information in read_all endpoint

This commit is contained in:
Lucien Greathouse 2018-05-30 22:37:49 -07:00
parent bf6766919e
commit 8df0565e0e
2 changed files with 12 additions and 1 deletions

View file

@ -38,7 +38,7 @@ pub fn serve(project_path: &PathBuf, port: Option<u64>) {
} }
let config = SessionConfig { let config = SessionConfig {
partitions partitions: partitions.clone(),
}; };
println!("Using session config {:#?}", config); println!("Using session config {:#?}", config);
@ -51,6 +51,7 @@ pub fn serve(project_path: &PathBuf, port: Option<u64>) {
server_id, server_id,
rbx_session: session.get_rbx_session(), rbx_session: session.get_rbx_session(),
message_session: session.get_message_session(), message_session: session.get_message_session(),
partitions,
}; };
println!("Server listening on port {}", web_config.port); println!("Server listening on port {}", web_config.port);

View file

@ -8,6 +8,7 @@ use id::Id;
use rbx::RbxInstance; use rbx::RbxInstance;
use rbx_session::RbxSession; use rbx_session::RbxSession;
use message_session::{MessageSession, Message}; use message_session::{MessageSession, Message};
use partition::Partition;
/// The set of configuration the web server needs to start. /// The set of configuration the web server needs to start.
pub struct WebConfig { pub struct WebConfig {
@ -15,6 +16,7 @@ pub struct WebConfig {
pub server_id: u64, pub server_id: u64,
pub rbx_session: Arc<RwLock<RbxSession>>, pub rbx_session: Arc<RwLock<RbxSession>>,
pub message_session: MessageSession, pub message_session: MessageSession,
pub partitions: HashMap<String, Partition>,
} }
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
@ -30,6 +32,7 @@ struct ServerInfoResponse<'a> {
struct ReadAllResponse<'a> { struct ReadAllResponse<'a> {
server_id: &'a str, server_id: &'a str,
instances: &'a HashMap<Id, RbxInstance>, instances: &'a HashMap<Id, RbxInstance>,
partitions: &'a HashMap<String, &'a [String]>,
message_cursor: i32, message_cursor: i32,
} }
@ -121,9 +124,16 @@ pub fn start(config: WebConfig) {
messages.len() as i32 - 1 messages.len() as i32 - 1
}; };
let mut partitions = HashMap::new();
for partition in config.partitions.values() {
partitions.insert(partition.name.clone(), partition.target.as_slice());
}
json_response(ReadAllResponse { json_response(ReadAllResponse {
server_id: &server_id, server_id: &server_id,
message_cursor, message_cursor,
partitions: &partitions,
instances: &rbx_session.instances, instances: &rbx_session.instances,
}) })
}, },