Skip to content

Commit

Permalink
feat: add v2 serving compat
Browse files Browse the repository at this point in the history
  • Loading branch information
macjuul committed Jun 13, 2024
1 parent 7291b1e commit bd57869
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
25 changes: 20 additions & 5 deletions src-tauri/src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
thread,
time::Instant,
};
use log::info;
use tauri::Manager;

mod shell;
Expand All @@ -22,6 +23,7 @@ pub fn start_database(
driver: &str,
storage: &str,
executable: &str,
v2_compat: bool,
) -> Result<(), String> {
let mut process = state.0.lock().unwrap();
let start_at = Instant::now();
Expand All @@ -34,7 +36,11 @@ pub fn start_database(
return Ok(());
}

let child_result = start_surreal_process(username, password, port, driver, storage, executable);
info!("Serving database with username: {}, password: {}, port: {}, driver: {}, storage: {}, executable: {}, v2_compat: {}", username, password, port, driver, storage, executable, v2_compat);

let child_result = start_surreal_process(
username, password, port, driver, storage, executable, v2_compat,
);
let mut child_proc = match child_result {
Ok(child) => child,
Err(err) => {
Expand Down Expand Up @@ -138,17 +144,26 @@ pub fn start_surreal_process(
driver: &str,
storage: &str,
executable: &str,
v2_compat: bool,
) -> Result<Child, String> {
let bind_addr = format!("0.0.0.0:{}", port);
let path = if executable.is_empty() {
"surreal"
} else {
executable
};
let mut args = vec![
path, "start", "--auth", "--bind", &bind_addr, "--user", username, "--pass", password,
"--log", "debug",
];

let mut args = if v2_compat {
vec![
path, "start", "--bind", &bind_addr, "--user", username, "--pass", password, "--log",
"debug",
]
} else {
vec![
path, "start", "--auth", "--bind", &bind_addr, "--user", username, "--pass", password,
"--log", "debug",
]
};

let file_uri = format!("file:https://{}", storage);
let tikv_uri = format!("tikv:https://{}", storage);
Expand Down
2 changes: 2 additions & 0 deletions src/adapter/desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { handleIntentRequest } from "~/util/intents";
import { VIEW_MODES } from "~/constants";
import { useInterfaceStore } from "~/stores/interface";
import { adapter } from ".";
import { featureFlags } from "~/util/feature-flags";

const WAIT_DURATION = 1000;

Expand Down Expand Up @@ -172,6 +173,7 @@ export class DesktopAdapter implements SurrealistAdapter {
driver: localDriver,
storage: localPath,
executable: surrealPath,
v2Compat: featureFlags.get('surreal_compat') === 'v2'
});
}

Expand Down
10 changes: 8 additions & 2 deletions src/util/feature-flags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export const schema = {
highlight_tool: {
options: [false, true],
},
surreal_compat: {
options: ['v1', 'v2'],
},
changelog: {
options: ['auto', 'hidden', 'read', 'unread'],
},
Expand All @@ -42,18 +45,21 @@ export const featureFlags = new FeatureFlags({
apidocs_view: true,
newsfeed: true,
highlight_tool: true,
surreal_compat: 'v1'
},
preview: {
database_version_check: true,
models_view: true,
apidocs_view: true,
newsfeed: true
newsfeed: true,
surreal_compat: 'v1'
},
production: {
database_version_check: true,
models_view: true,
apidocs_view: true,
newsfeed: true
newsfeed: true,
surreal_compat: 'v1'
},
},
overrides: (flag) => {
Expand Down

0 comments on commit bd57869

Please sign in to comment.