Skip to content

Commit

Permalink
Upgrade to latest plus QoL improvements. (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoEight authored Dec 24, 2024
1 parent 9d799a4 commit cc8ae0a
Show file tree
Hide file tree
Showing 22 changed files with 390 additions and 630 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
run: rustup update stable

- name: Generate certificates
run: docker-compose --file configure-tls-for-tests.yml up
run: docker compose --file configure-tls-for-tests.yml up

- name: Run test
run: cargo test --package eventstore --test integration single_node_${{ matrix.test }}
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
run: rustup update stable

- name: Set up cluster with Docker Compose
run: docker-compose up -d
run: docker compose up -d
env:
ESDB_DOCKER_REPO: ${{ needs.provide_docker.outputs.docker_repo }}
ESDB_DOCKER_CONTAINER: ${{ needs.provide_docker.outputs.docker_container }}
Expand All @@ -118,4 +118,4 @@ jobs:
RUST_BACKTRACE: 1

- name: Shutdown cluster
run: docker-compose down
run: docker compose down
33 changes: 16 additions & 17 deletions eventstore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,42 @@ categories = ["database", "api-bindings"]

[dependencies]
async-stream = "0.3"
base64 = "0.13"
base64 = "0.22"
bitflags = "2"
byteorder = "1.2"
byteorder = "1"
bytes = "1"
chrono = { version = "0.4", default-features = false, features = ["std", "serde"] }
eventstore-macros = { path = "../eventstore-macros", version = "0.0.1" }
futures = "0.3"
http = "0.2"
hyper = { version = "0.14", features = ["client", "tcp"] }
hyper-rustls = { version = "0.23", features = ["rustls-native-certs", "http2"] }
http = "1"
hyper = { version = "1", features = ["client"] }
hyper-util = { version = "0.1", features = ["client-legacy", "http2"] }
hyper-rustls = { version = "0.27", features = ["rustls-native-certs", "http2"] }
log = "0.4"
nom = "7"
prost = "0.12"
prost-derive = "0.12"
prost-types = "0.12"
prost = "0.13"
prost-types = "0.13"
rand = { version = "0.8", features = ["small_rng"] }
reqwest = { version = "0.11", default-features = false, features = [
reqwest = { version = "0.12", default-features = false, features = [
"rustls-tls",
"rustls-tls-native-roots",
"json",
] }
rustls = { version = "0.20", features = ["dangerous_configuration"] }
rustls-native-certs = "0.6"
rustls = { version = "0.23" }
rustls-native-certs = "0.8"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "1"
thiserror = "2"
tokio = { version = "1", default-features = false, features = ["time"] }
tokio-rustls = "0.23"
tonic = { version = "0.10", features = ["tls", "tls-roots"] }
tower = "0.4"
tokio-rustls = "0.26"
tonic = { version = "0.12", features = ["tls", "tls-roots"] }
tower = "0.5"
url = "2"
urlencoding = "2"
uuid = { version = "1", features = ["v4", "serde"] }
webpki = "0.22"

[build-dependencies]
tonic-build = { version = "0.10.2", features = ["prost-build"] }
tonic-build = { version = "0.12", features = ["prost-build"] }

[[test]]
name = "integration"
Expand Down
12 changes: 6 additions & 6 deletions eventstore/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn generate() -> Result<(), Box<dyn std::error::Error>> {
.extern_path(".event_store.client.Empty", "()")
.bytes(&["StreamIdentifier.stream_name"])
.out_dir(out_dir)
.compile(&files, &[""])?;
.compile_protos(&files, &[""])?;

for entry in std::fs::read_dir(out_dir)? {
let file = entry.unwrap();
Expand All @@ -25,7 +25,7 @@ pub fn generate() -> Result<(), Box<dyn std::error::Error>> {

let new_file = file.path().parent().unwrap().join("common.rs");

std::fs::rename(file.path(), new_file)?;
fs::rename(file.path(), new_file)?;
}
}

Expand All @@ -40,7 +40,7 @@ pub fn generate() -> Result<(), Box<dyn std::error::Error>> {
"protos/users.proto",
];

std::fs::create_dir_all(out_dir)?;
fs::create_dir_all(out_dir)?;

tonic_build::configure()
.build_server(false)
Expand All @@ -67,7 +67,7 @@ pub fn generate() -> Result<(), Box<dyn std::error::Error>> {
".event_store.client.UUID",
"crate::event_store::generated::common::Uuid",
)
.compile(&files, &["protos"])?;
.compile_protos(&files, &["protos"])?;

for entry in std::fs::read_dir(out_dir)? {
let file = entry.unwrap();
Expand All @@ -87,10 +87,10 @@ pub fn generate() -> Result<(), Box<dyn std::error::Error>> {

let new_file = file.path().parent().unwrap().join(new_file_name);

std::fs::rename(file.path(), new_file)?;
fs::rename(file.path(), new_file)?;
} else if filename_string.as_str() == "google.rpc.rs" {
let new_file = file.path().parent().unwrap().join("google_rpc.rs");
std::fs::rename(file.path(), new_file)?;
fs::rename(file.path(), new_file)?;
}
}

Expand Down
2 changes: 1 addition & 1 deletion eventstore/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Client {
&self,
name: impl MetadataStreamName,
options: &AppendToStreamOptions,
metadata: StreamMetadata,
metadata: &StreamMetadata,
) -> crate::Result<WriteResult> {
let event = EventData::json("$metadata", metadata)
.map_err(|e| crate::Error::InternalParsingError(e.to_string()))?;
Expand Down
2 changes: 1 addition & 1 deletion eventstore/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub async fn append_to_stream(
});
let header = Content::Options(append_req::Options {
stream_identifier,
expected_stream_revision: Some(options.version.clone()),
expected_stream_revision: Some(options.version),
});
let header = AppendReq {
content: Some(header),
Expand Down
36 changes: 11 additions & 25 deletions eventstore/src/event_store/generated/common.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#[allow(clippy::derive_partial_eq_without_eq)]
// This file is @generated by prost-build.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Uuid {
#[prost(oneof = "uuid::Value", tags = "1, 2")]
pub value: ::core::option::Option<uuid::Value>,
}
/// Nested message and enum types in `UUID`.
pub mod uuid {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Structured {
#[prost(int64, tag = "1")]
pub most_significant_bits: i64,
#[prost(int64, tag = "2")]
pub least_significant_bits: i64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Value {
#[prost(message, tag = "1")]
Expand All @@ -23,22 +21,19 @@ pub mod uuid {
String(::prost::alloc::string::String),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StreamIdentifier {
#[prost(bytes = "bytes", tag = "3")]
pub stream_name: ::prost::bytes::Bytes,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct AllStreamPosition {
#[prost(uint64, tag = "1")]
pub commit_position: u64,
#[prost(uint64, tag = "2")]
pub prepare_position: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct WrongExpectedVersion {
#[prost(
oneof = "wrong_expected_version::CurrentStreamRevisionOption",
Expand All @@ -55,16 +50,14 @@ pub struct WrongExpectedVersion {
}
/// Nested message and enum types in `WrongExpectedVersion`.
pub mod wrong_expected_version {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
#[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
pub enum CurrentStreamRevisionOption {
#[prost(uint64, tag = "1")]
CurrentStreamRevision(u64),
#[prost(message, tag = "2")]
CurrentNoStream(()),
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
#[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
pub enum ExpectedStreamPositionOption {
#[prost(uint64, tag = "3")]
ExpectedStreamPosition(u64),
Expand All @@ -76,31 +69,24 @@ pub mod wrong_expected_version {
ExpectedNoStream(()),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct AccessDenied {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StreamDeleted {
#[prost(message, optional, tag = "1")]
pub stream_identifier: ::core::option::Option<StreamIdentifier>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Timeout {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Unknown {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct InvalidTransaction {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct MaximumAppendSizeExceeded {
#[prost(uint32, tag = "1")]
pub max_append_size: u32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BadRequest {
#[prost(string, tag = "1")]
Expand Down
36 changes: 18 additions & 18 deletions eventstore/src/event_store/generated/google_rpc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
/// The canonical error codes for gRPC APIs.
///
///
Expand Down Expand Up @@ -153,23 +154,23 @@ impl Code {
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Code::Ok => "OK",
Code::Cancelled => "CANCELLED",
Code::Unknown => "UNKNOWN",
Code::InvalidArgument => "INVALID_ARGUMENT",
Code::DeadlineExceeded => "DEADLINE_EXCEEDED",
Code::NotFound => "NOT_FOUND",
Code::AlreadyExists => "ALREADY_EXISTS",
Code::PermissionDenied => "PERMISSION_DENIED",
Code::Unauthenticated => "UNAUTHENTICATED",
Code::ResourceExhausted => "RESOURCE_EXHAUSTED",
Code::FailedPrecondition => "FAILED_PRECONDITION",
Code::Aborted => "ABORTED",
Code::OutOfRange => "OUT_OF_RANGE",
Code::Unimplemented => "UNIMPLEMENTED",
Code::Internal => "INTERNAL",
Code::Unavailable => "UNAVAILABLE",
Code::DataLoss => "DATA_LOSS",
Self::Ok => "OK",
Self::Cancelled => "CANCELLED",
Self::Unknown => "UNKNOWN",
Self::InvalidArgument => "INVALID_ARGUMENT",
Self::DeadlineExceeded => "DEADLINE_EXCEEDED",
Self::NotFound => "NOT_FOUND",
Self::AlreadyExists => "ALREADY_EXISTS",
Self::PermissionDenied => "PERMISSION_DENIED",
Self::Unauthenticated => "UNAUTHENTICATED",
Self::ResourceExhausted => "RESOURCE_EXHAUSTED",
Self::FailedPrecondition => "FAILED_PRECONDITION",
Self::Aborted => "ABORTED",
Self::OutOfRange => "OUT_OF_RANGE",
Self::Unimplemented => "UNIMPLEMENTED",
Self::Internal => "INTERNAL",
Self::Unavailable => "UNAVAILABLE",
Self::DataLoss => "DATA_LOSS",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
Expand Down Expand Up @@ -203,7 +204,6 @@ impl Code {
///
/// You can find out more about this error model and how to work with it in the
/// [API Design Guide](<https://cloud.google.com/apis/design/errors>).
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Status {
/// The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
Expand Down
Loading

0 comments on commit cc8ae0a

Please sign in to comment.