Skip to content

Commit

Permalink
version bump, replace lazy_static
Browse files Browse the repository at this point in the history
  • Loading branch information
ddboline committed Dec 25, 2023
1 parent a9ef19e commit 614a4a4
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 44 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "diary_app_rust"
version = "0.10.5"
version = "0.10.6"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -15,14 +15,14 @@ Daily journal"""
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0"
diary_app_lib = {path="diary_app_lib"}
diary_app_api = {path="diary_app_api"}
diary_app_bot = {path="diary_app_bot"}
env_logger = "0.10"
tokio = {version="1.35", features=["rt", "macros", "rt-multi-thread"]}
dirs = "5.0"
anyhow = "1.0"
env_logger = "0.10"
time = {version="0.3", features=["serde-human-readable", "macros", "formatting"]}
tokio = {version="1.35", features=["rt", "macros", "rt-multi-thread"]}

[workspace]
members = [
Expand Down
9 changes: 4 additions & 5 deletions diary_app_api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "diary_app_api"
version = "0.10.5"
version = "0.10.6"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -9,7 +9,7 @@ edition = "2018"
[dependencies]
anyhow = "1.0"
async-trait = "0.1"
authorized_users = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.8"}
authorized_users = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.9"}
aws-config = {version="1.0", features=["behavior-version-latest"]}
diary_app_lib = {path = "../diary_app_lib"}
dioxus = "0.4"
Expand All @@ -18,7 +18,6 @@ derive_more = "0.99"
futures = "0.3"
handlebars = "4.0"
itertools = "0.12"
lazy_static = "1.4"
log = "0.4"
maplit = "1.0"
parking_lot = "0.12"
Expand All @@ -37,7 +36,7 @@ tokio = {version="1.35", features=["time"]}
uuid = "1.0"

[dev-dependencies]
auth_server_http = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.8"}
auth_server_lib = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.8"}
auth_server_http = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.9"}
auth_server_lib = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.9"}
env_logger = "0.10"
reqwest = {version="0.11", features=["cookies", "json", "rustls-tls", "stream"]}
2 changes: 1 addition & 1 deletion diary_app_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ derive_rweb_schema!(ConflictData, _ConflictData);

#[allow(dead_code)]
#[derive(Schema)]
#[schema(component="ConflictData")]
#[schema(component = "ConflictData")]
struct _ConflictData {
#[schema(description = "Conflict Date")]
pub date: Option<DateType>,
Expand Down
4 changes: 2 additions & 2 deletions diary_app_api/src/logged_user.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use authorized_users::{
get_random_key, get_secrets, token::Token, AuthorizedUser, AUTHORIZED_USERS, JWT_SECRET,
KEY_LENGTH, SECRET_KEY, TRIGGER_DB_UPDATE, LOGIN_HTML
KEY_LENGTH, LOGIN_HTML, SECRET_KEY, TRIGGER_DB_UPDATE,
};
use futures::TryStreamExt;
use log::debug;
Expand All @@ -21,7 +21,7 @@ use diary_app_lib::{models::AuthorizedUsers, pgpool::PgPool};
use crate::errors::ServiceError as Error;

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone, Schema)]
#[schema(component="LoggedUser")]
#[schema(component = "LoggedUser")]
pub struct LoggedUser {
#[schema(description = "Email Address")]
pub email: StackString,
Expand Down
6 changes: 3 additions & 3 deletions diary_app_api/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async fn search_results(query: SearchOptions, state: AppState) -> HttpResult<Vec
}

#[derive(Serialize, Deserialize, Schema)]
#[schema(component="InsertData")]
#[schema(component = "InsertData")]
pub struct InsertData {
#[schema(description = "Text to Insert")]
pub text: StackString,
Expand Down Expand Up @@ -159,7 +159,7 @@ pub async fn sync_api(
}

#[derive(Serialize, Deserialize, Schema)]
#[schema(component="ReplaceData")]
#[schema(component = "ReplaceData")]
pub struct ReplaceData {
#[schema(description = "Replacement Date")]
pub date: DateType,
Expand Down Expand Up @@ -238,7 +238,7 @@ async fn list_api_body(query: ListOptions, state: &AppState) -> HttpResult<Vec<D
}

#[derive(Schema, Serialize)]
#[schema(component="ListOutput")]
#[schema(component = "ListOutput")]
struct ListOutput {
list: Vec<DateType>,
}
Expand Down
16 changes: 8 additions & 8 deletions diary_app_bot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[package]
name = "diary_app_bot"
version = "0.10.5"
version = "0.10.6"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
diary_app_lib = {path="../diary_app_lib"}
anyhow = "1.0"
aws-config = {version="1.0", features=["behavior-version-latest"]}
log = "0.4"
futures = "0.3"
crossbeam-channel = "0.5"
parking_lot = "0.12"
crossbeam-utils = "0.8"
lazy_static = "1.4"
anyhow = "1.0"
diary_app_lib = {path="../diary_app_lib"}
futures = "0.3"
log = "0.4"
once_cell = "1.0"
parking_lot = "0.12"
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.2" }
thiserror = "1.0"
tokio = {version="1.35", features=["rt", "macros", "rt-multi-thread"]}
telegram-bot = {git = "https://github.com/ddboline/telegram-bot.git", tag="0.9.0-4", default_features=false}
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.2" }
10 changes: 4 additions & 6 deletions diary_app_bot/src/telegram_bot.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Error;
use futures::{future::join, StreamExt, TryStreamExt};
use lazy_static::lazy_static;
use log::debug;
use once_cell::sync::Lazy;
use stack_string::{format_sstr, StackString};
use std::collections::HashSet;
use telegram_bot::{types::refs::UserId, Api, CanReplySendMessage, MessageKind, UpdateKind};
Expand All @@ -23,11 +23,9 @@ use crate::failure_count::FailureCount;
type UserIds = RwLock<HashSet<UserId>>;
type OBuffer = RwLock<Vec<StackString>>;

lazy_static! {
static ref TELEGRAM_USERIDS: UserIds = RwLock::new(HashSet::new());
static ref OUTPUT_BUFFER: OBuffer = RwLock::new(Vec::new());
static ref FAILURE_COUNT: FailureCount = FailureCount::new(5);
}
static TELEGRAM_USERIDS: Lazy<UserIds> = Lazy::new(|| RwLock::new(HashSet::new()));
static OUTPUT_BUFFER: Lazy<OBuffer> = Lazy::new(|| RwLock::new(Vec::new()));
static FAILURE_COUNT: Lazy<FailureCount> = Lazy::new(|| FailureCount::new(5));

async fn diary_sync(
dapp_interface: DiaryAppInterface,
Expand Down
4 changes: 2 additions & 2 deletions diary_app_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "diary_app_lib"
version = "0.10.5"
version = "0.10.6"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -22,8 +22,8 @@ dotenv = "0.15"
envy = "0.4"
futures = "0.3"
jwalk = "0.8"
lazy_static = "1.4"
log = "0.4"
once_cell = "1.0"
parking_lot = "0.12"
postgres-types = "0.2"
postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.6", features=["deadpool"]}
Expand Down
6 changes: 2 additions & 4 deletions diary_app_lib/src/date_time_wrapper.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use bytes::BytesMut;
use derive_more::{Deref, DerefMut, From, Into};
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use postgres_types::{FromSql, IsNull, ToSql, Type};
use serde::{Deserialize, Serialize};
use std::fmt;
use time::OffsetDateTime;
use time_tz::{timezones::db::UTC, Tz};

lazy_static! {
static ref LOCAL_TZ: &'static Tz = time_tz::system::get_timezone().unwrap_or(UTC);
}
static LOCAL_TZ: Lazy<&'static Tz> = Lazy::new(|| time_tz::system::get_timezone().unwrap_or(UTC));

#[derive(
Serialize,
Expand Down
8 changes: 3 additions & 5 deletions diary_app_lib/src/s3_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use anyhow::{format_err, Error};
use aws_config::SdkConfig;
use aws_sdk_s3::types::Object;
use futures::{stream::FuturesUnordered, TryStreamExt};
use lazy_static::lazy_static;
use log::debug;
use once_cell::sync::Lazy;
use stack_string::{format_sstr, StackString};
use std::{
collections::HashMap,
Expand All @@ -17,10 +17,8 @@ use crate::{config::Config, models::DiaryEntries, pgpool::PgPool, s3_instance::S

const TIME_BUFFER: i64 = 60;

lazy_static! {
static ref KEY_CACHE: RwLock<(OffsetDateTime, Arc<[KeyMetaData]>)> =
RwLock::new((OffsetDateTime::now_utc(), Arc::new([])));
}
static KEY_CACHE: Lazy<RwLock<(OffsetDateTime, Arc<[KeyMetaData]>)>> =
Lazy::new(|| RwLock::new((OffsetDateTime::now_utc(), Arc::new([]))));

#[derive(Debug, Clone)]
struct KeyMetaData {
Expand Down
7 changes: 3 additions & 4 deletions diary_app_lib/src/ssh_instance.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{format_err, Error};
use lazy_static::lazy_static;
use log::debug;
use once_cell::sync::Lazy;
use smallvec::{smallvec, SmallVec};
use std::{collections::HashMap, fmt::Display, process::Stdio};
use tokio::{
Expand All @@ -12,9 +12,8 @@ use url::Url;

use stack_string::{format_sstr, StackString};

lazy_static! {
static ref LOCK_CACHE: RwLock<HashMap<StackString, Mutex<()>>> = RwLock::new(HashMap::new());
}
static LOCK_CACHE: Lazy<RwLock<HashMap<StackString, Mutex<()>>>> =
Lazy::new(|| RwLock::new(HashMap::new()));

#[derive(Debug, Clone)]
pub struct SSHInstance {
Expand Down

0 comments on commit 614a4a4

Please sign in to comment.