fix(kafka): improve mq admin compatibility
This commit is contained in:
1 parent
e4e4fa8482
commit
72a7207283
24 files changed
+1050
-170
No files matched your search
@@ -737,8 +737,17 @@ pub async fn test_connection(state: State<'_, Arc<AppState>>, config: Connection
|
||||
DatabaseType::MessageQueue => {
|
||||
let mqc = state.mq_admin_config_for_connection(connection_id, &config).await?;
|
||||
let kafka_launch = dbx_core::mq::service::resolve_kafka_launch_spec(&mqc, &state);
|
||||
let adapter = state.mq_registry.build_transient_config(mqc, kafka_launch).await?;
|
||||
adapter.test_connection().await?;
|
||||
let adapter = match state.mq_registry.get_or_build_config(connection_id, mqc, kafka_launch).await {
|
||||
Ok(adapter) => adapter,
|
||||
Err(err) => {
|
||||
state.mq_registry.drop_connection(connection_id).await;
|
||||
return Err(err);
|
||||
}
|
||||
};
|
||||
if let Err(err) = adapter.test_connection().await {
|
||||
state.mq_registry.drop_connection(connection_id).await;
|
||||
return Err(err);
|
||||
}
|
||||
Ok("Connection successful".to_string())
|
||||
}
|
||||
#[cfg(not(feature = "mq-admin"))]
|
||||
@@ -1022,8 +1031,17 @@ pub async fn connect_db(state: State<'_, Arc<AppState>>, config: ConnectionConfi
|
||||
DatabaseType::MessageQueue => {
|
||||
let mqc = state.mq_admin_config_for_connection(&id, &config).await?;
|
||||
let kafka_launch = dbx_core::mq::service::resolve_kafka_launch_spec(&mqc, &state);
|
||||
let adapter = state.mq_registry.build_transient_config(mqc, kafka_launch).await?;
|
||||
adapter.test_connection().await?;
|
||||
let adapter = match state.mq_registry.get_or_build_config(&id, mqc, kafka_launch).await {
|
||||
Ok(adapter) => adapter,
|
||||
Err(err) => {
|
||||
state.mq_registry.drop_connection(&id).await;
|
||||
return Err(err);
|
||||
}
|
||||
};
|
||||
if let Err(err) = adapter.test_connection().await {
|
||||
state.mq_registry.drop_connection(&id).await;
|
||||
return Err(err);
|
||||
}
|
||||
PoolKind::MessageQueue
|
||||
}
|
||||
#[cfg(not(feature = "mq-admin"))]
|
||||
|
||||
@@ -253,8 +253,9 @@ pub async fn mq_peek_messages(
|
||||
topic: dbx_core::mq::TopicRef,
|
||||
sub: String,
|
||||
count: u32,
|
||||
options: Option<dbx_core::mq::PeekMessagesOptions>,
|
||||
) -> Result<Vec<dbx_core::mq::PeekedMessage>, String> {
|
||||
dbx_core::mq::service::mq_peek_messages_core(&state, &connection_id, topic, sub, count).await
|
||||
dbx_core::mq::service::mq_peek_messages_core(&state, &connection_id, topic, sub, count, options).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
Reference in new issue
Block a user