Skip to content

Commit 078bc9a

Browse files
authored
fix: compilation and linting issues (#323)
The repo hasn't seen some action in a while, and needed some upkeeping. What's more, the `examples` folder did not have a `Cargo.lock` (since it was part of the virtual workspace). This PR fixes all those issues, and makes the CI green again.
1 parent d5cc7f7 commit 078bc9a

File tree

13 files changed

+3373
-61
lines changed

13 files changed

+3373
-61
lines changed

.clippy.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
allowed-duplicate-crates = [
2+
"syn",
3+
# These are all coming from eventually-postgres, quite likely sqlx...
4+
"hashbrown",
5+
"wasi",
6+
"windows-sys",
7+
"windows-targets",
8+
"windows_aarch64_gnullvm",
9+
"windows_aarch64_msvc",
10+
"windows_i686_gnu",
11+
"windows_i686_msvc",
12+
"windows_x86_64_gnu",
13+
"windows_x86_64_gnullvm",
14+
"windows_x86_64_msvc",
15+
"zerocopy",
16+
"zerocopy-derive",
17+
"getrandom",
18+
]

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
**/target
22
**/*.rs.bk
3-
Cargo.lock
3+
/Cargo.lock
44
lcov.info
5-
65
.direnv

.vscode/settings.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
22
"rust-analyzer.cargo.features": "all",
3-
"rust-analyzer.check.command": "clippy"
3+
"rust-analyzer.check.command": "clippy",
4+
"nix.serverPath": "nil",
5+
"nix.enableLanguageServer": true,
6+
"nix.serverSettings": {
7+
"nil": {
8+
"formatting": {
9+
"command": ["nixpkgs-fmt"]
10+
}
11+
}
12+
},
413
}

Cargo.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
[workspace]
22
resolver = "2"
3-
members = [
4-
"eventually",
5-
"eventually-macros",
6-
"eventually-postgres",
7-
8-
# Crates as examples
9-
"examples/bank-accounting",
10-
]
3+
members = ["eventually", "eventually-macros", "eventually-postgres"]
4+
exclude = ["examples/bank-accounting"]

eventually-postgres/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ pub mod event;
1313

1414
pub(crate) static MIGRATIONS: sqlx::migrate::Migrator = sqlx::migrate!("./migrations");
1515

16+
use std::sync::LazyLock;
17+
1618
use eventually::version::{ConflictError, Version};
17-
use lazy_static::lazy_static;
1819
use regex::Regex;
1920

20-
lazy_static! {
21-
static ref CONFLICT_ERROR_REGEX: Regex =
22-
Regex::new(r"version check failed, expected: (?P<expected>\d), got: (?P<got>\d)")
23-
.expect("regex compiles successfully");
24-
}
21+
static CONFLICT_ERROR_REGEX: LazyLock<Regex> = LazyLock::new(|| {
22+
Regex::new(r"version check failed, expected: (?P<expected>\d), got: (?P<got>\d)")
23+
.expect("regex compiles successfully")
24+
});
2525

2626
pub(crate) fn check_for_conflict_error(err: &sqlx::Error) -> Option<ConflictError> {
2727
fn capture_to_version(captures: &regex::Captures, name: &'static str) -> Version {

eventually/src/aggregate/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,15 @@ where
246246
#[derive(Debug, thiserror::Error)]
247247
pub enum RehydrateError<T, I> {
248248
/// Error returned during rehydration when the [Aggregate Root][Root]
249-
/// is applying a Domain Event using [Aggregate::apply].
249+
/// is applying a Domain Event using [`Aggregate::apply`].
250250
///
251251
/// This usually implies the Event Stream for the [Aggregate]
252252
/// contains corrupted or unexpected data.
253253
#[error("failed to apply domain event while rehydrating aggregate: {0}")]
254254
Domain(#[source] T),
255255

256-
/// This error is returned by [Root::rehydrate_async] when the underlying
257-
/// [futures::TryStream] has returned an error.
256+
/// This error is returned by [`Root::rehydrate_async`] when the underlying
257+
/// [`futures::TryStream`] has returned an error.
258258
#[error("failed to rehydrate aggregate from event stream: {0}")]
259259
Inner(#[source] I),
260260
}
@@ -556,7 +556,7 @@ mod tests {
556556
{
557557
assert!(error
558558
.source()
559-
.map_or(false, |src| src.is::<version::ConflictError>()));
559+
.is_some_and(|src| src.is::<version::ConflictError>()));
560560
}
561561
}
562562
}

eventually/src/aggregate/repository.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ where
3939
/// All possible errors returned by [`Saver::save`].
4040
#[derive(Debug, thiserror::Error)]
4141
pub enum SaveError {
42-
/// Error returned when [Saver::save] encounters a conflict error while saving the new Aggregate Root.
42+
/// Error returned when [`Saver::save`] encounters a conflict error while saving the new Aggregate Root.
4343
#[error("failed to save aggregate root: {0}")]
4444
Conflict(#[from] version::ConflictError),
4545
/// Error returned when the [Saver] implementation has encountered an error.

eventually/src/command/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,6 @@ where
163163
assert_eq!(events, recorded_events);
164164
},
165165
ScenarioThenCase::Fails => assert!(result.is_err()),
166-
};
166+
}
167167
}
168168
}

eventually/src/event/store.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ where
3333
/// All possible error types returned by [`Appender::append`].
3434
#[derive(Debug, thiserror::Error)]
3535
pub enum AppendError {
36-
/// Error returned when [Appender::append] encounters a conflict error
36+
/// Error returned when [`Appender::append`] encounters a conflict error
3737
/// while appending the new Domain Events.
3838
#[error("failed to append new domain events: {0}")]
3939
Conflict(#[from] version::ConflictError),
@@ -343,8 +343,9 @@ where
343343
#[allow(clippy::semicolon_if_nothing_returned)] // False positives :shrugs:
344344
#[cfg(test)]
345345
mod test {
346+
use std::sync::LazyLock;
347+
346348
use futures::TryStreamExt;
347-
use lazy_static::lazy_static;
348349

349350
use super::*;
350351
use crate::event;
@@ -354,13 +355,13 @@ mod test {
354355

355356
const STREAM_ID: &str = "stream:test";
356357

357-
lazy_static! {
358-
static ref EVENTS: Vec<event::Envelope<StringMessage>> = vec![
358+
static EVENTS: LazyLock<Vec<event::Envelope<StringMessage>>> = LazyLock::new(|| {
359+
vec![
359360
event::Envelope::from(StringMessage("event-1")),
360361
event::Envelope::from(StringMessage("event-2")),
361362
event::Envelope::from(StringMessage("event-3")),
362-
];
363-
}
363+
]
364+
});
364365

365366
#[tokio::test]
366367
async fn it_works() {

0 commit comments

Comments
 (0)