Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
anstadnik committed May 4, 2024
1 parent de25e85 commit 3ed742a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 5 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build_flutter_apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ jobs:
- uses: baptiste0928/cargo-install@v2
with:
crate: flutter_rust_bridge_codegen
version: 2.0.0-dev.0
- uses: baptiste0928/cargo-install@v2
with:
crate: cargo-ndk
version: 2.0.0-dev.32
# - uses: baptiste0928/cargo-install@v2
# with:
# crate: cargo-ndk
- uses: baptiste0928/cargo-install@v2
with:
crate: cargo-expand
# - run: flutter_rust_bridge_codegen build && flutter build apk --release
- run: flutter build apk --release
env:
SHEET_ID: ${{ secrets.SHEET_ID }}
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
crate-type = ["cdylib", "staticlib"]

[dependencies]
openssl = { version = "0.10", features = ["vendored"] }
first_aid_bot_core = { path = "../../core" }
flutter_rust_bridge = "=2.0.0-dev.32"
anyhow = { workspace = true }
2 changes: 1 addition & 1 deletion app/rust/src/api/fa_api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use flutter_rust_bridge::frb;
use std::{borrow::Cow, env::set_var};
use std::borrow::Cow;

use anyhow::{bail, Result};
pub use first_aid_bot_core::prelude::*;
Expand Down
35 changes: 35 additions & 0 deletions bot/src/bot/init_connections.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::sync::Arc;

use crate::REDIS_URLS;
use anyhow::{anyhow, Result};
use first_aid_bot_core::prelude::Data;
use futures::future::join_all;
use redis::{aio::MultiplexedConnection, Client};
use teloxide::dispatching::dialogue::{serializer::Bincode, RedisStorage};

async fn connect_to_redis() -> Result<(MultiplexedConnection, Arc<RedisStorage<Bincode>>)> {
join_all(REDIS_URLS.into_iter().map(|url| async move {
let connection = Client::open(url)?.get_multiplexed_tokio_connection().await;
anyhow::Ok((connection?, RedisStorage::open(url, Bincode).await?))
}))
.await
.into_iter()
.flatten()
.next()
.ok_or(anyhow!("No redis connection"))
}

async fn init_data() -> Result<Data> {
if cfg!(debug_assertions) {
Ok(Data::dynamic())
} else {
Data::cached()
}
}

pub async fn init_connections() -> Result<(MultiplexedConnection, Arc<RedisStorage<Bincode>>, Data)>
{
let (redis_conn, storage) = connect_to_redis().await?;
let data = init_data().await?;
Ok((redis_conn, storage, data))
}

0 comments on commit 3ed742a

Please sign in to comment.