feat: integrate postgres storage (#2604)

* chore: env config

* chore: get user workspace

* feat: enable postgres storage

* chore: add new env

* chore: add set env ffi

* chore: pass env before backend init

* chore: update

* fix: ci tests

* chore: commit the generate env file

* chore: remove unused import
This commit is contained in:
Nathan.fooo
2023-05-23 23:55:21 +08:00
committed by GitHub
parent 51a7954af7
commit 056e2d49d0
87 changed files with 1421 additions and 1131 deletions

View File

@ -0,0 +1,19 @@
use appflowy_integrate::SupabaseDBConfig;
use flowy_server::supabase::SupabaseConfiguration;
use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct AppFlowyEnv {
supabase_config: SupabaseConfiguration,
supabase_db_config: SupabaseDBConfig,
}
impl AppFlowyEnv {
pub fn parser(env_str: &str) {
if let Ok(env) = serde_json::from_str::<AppFlowyEnv>(env_str) {
dbg!(&env);
env.supabase_config.write_env();
env.supabase_db_config.write_env();
}
}
}

View File

@ -10,6 +10,7 @@ use flowy_notification::register_notification_sender;
use lib_dispatch::prelude::ToBytes;
use lib_dispatch::prelude::*;
use crate::env_serde::AppFlowyEnv;
use crate::notification::DartNotificationSender;
use crate::{
c::{extend_front_four_bytes_into_bytes, forget_rust},
@ -17,6 +18,7 @@ use crate::{
};
mod c;
mod env_serde;
mod model;
mod notification;
mod protobuf;
@ -134,3 +136,10 @@ pub extern "C" fn backend_log(level: i64, data: *const c_char) {
_ => (),
}
}
#[no_mangle]
pub extern "C" fn set_env(data: *const c_char) {
let c_str = unsafe { CStr::from_ptr(data) };
let serde_str = c_str.to_str().unwrap();
AppFlowyEnv::parser(serde_str);
}