Skip to content

Commit 8b76db1

Browse files
committed
✨ Desktop: Integrate backend with worker
1 parent 62bdc62 commit 8b76db1

4 files changed

Lines changed: 11 additions & 8 deletions

File tree

desktop/desktop-backend/src/backend.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ impl BackendState {
6161

6262
#[derive(Deserialize)]
6363
struct GetUnassingedTaskQuery {
64+
#[serde(rename = "task_type")]
6465
task_types: Vec<TaskType>,
6566
}
6667

desktop/src-tauri/src/backend_plugin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use tauri::{
99
};
1010
use tauri_plugin_log::log;
1111

12-
struct BackendState {
13-
local_addr: SocketAddr,
14-
token: String,
12+
pub struct BackendState {
13+
pub local_addr: SocketAddr,
14+
pub token: String,
1515
}
1616
pub fn init<R: Runtime>() -> TauriPlugin<R> {
1717
Builder::new("transcribee_backend")

desktop/src-tauri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ pub fn run() {
6767
)
6868
.plugin(tauri_plugin_shell::init())
6969
.plugin(tauri_plugin_opener::init())
70-
.plugin(worker_plugin::init())
7170
.plugin(backend_plugin::init())
71+
.plugin(worker_plugin::init())
7272
.invoke_handler(tauri::generate_handler![greet, ffmpeg_help])
7373
.run(tauri::generate_context!())
7474
.expect("error while running tauri application");

desktop/src-tauri/src/worker_plugin.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use tauri::{
77
};
88
use tauri_plugin_shell::ShellExt;
99

10+
use crate::backend_plugin::BackendState;
11+
1012
pub fn init<R: Runtime>() -> TauriPlugin<R> {
11-
// Make the plugin config optional
12-
// by using `Builder::<R, Option<Config>>` instead
13-
Builder::<R>::new("transcribee-worker")
13+
Builder::new("transcribee-worker")
1414
.setup(|app, _| {
1515
let ext = if cfg!(target_family = "windows") {
1616
"bat"
@@ -24,14 +24,16 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
2424
println!("{:?}", resource_path);
2525

2626
let app = app.clone();
27+
2728
tauri::async_runtime::spawn(async move {
2829
let shell = app.shell();
30+
let backend_state = app.state::<BackendState>();
2931

3032
loop {
3133
info!(target: "worker", "starting worker");
3234
let (mut events, _) = shell
3335
.command(resource_path.clone())
34-
.args(["--help"])
36+
.args(["--coordinator", &format!("http://{}:{}/", backend_state.local_addr.ip(), backend_state.local_addr.port()), "--token", &backend_state.token])
3537
.spawn()
3638
.unwrap();
3739

0 commit comments

Comments
 (0)