-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get rid of PublishedMessage derive (#18)
* feat: get rid of PublishedMessage derive * fix * fixes
- Loading branch information
1 parent
840c38d
commit 8bc7c4d
Showing
20 changed files
with
139 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pub-sub-client-tests/secrets/active-road-365118-2eca6b7b8fd9.json | ||
secrets/active-road-365118-2eca6b7b8fd9.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,6 @@ | ||
[workspace] | ||
members = [ | ||
"pub-sub-client", | ||
"pub-sub-client-derive", | ||
"pub-sub-client-tests", | ||
] | ||
resolver = "2" | ||
|
||
[workspace.package] | ||
# No use to define version here, because cargo release ignores it! | ||
# version = "0.10.1-alpha.0" | ||
[package] | ||
name = "pub-sub-client" | ||
version = "0.11.1-alpha.0" | ||
edition = "2021" | ||
description = "Google Cloud Pub/Sub client library" | ||
authors = [ "Heiko Seeberger <[email protected]>" ] | ||
|
@@ -17,23 +9,21 @@ readme = "README.md" | |
homepage = "https://github.com/hseeberger/pub-sub-client" | ||
repository = "https://github.com/hseeberger/pub-sub-client" | ||
documentation = "https://github.com/hseeberger/pub-sub-client" | ||
publish = true | ||
|
||
[workspace.dependencies] | ||
[dependencies] | ||
base64 = { version = "0.21" } | ||
goauth = { version = "0.13" } | ||
reqwest = { version = "0.11", features = [ "json" ] } | ||
serde = { version = "1.0", features = [ "derive" ] } | ||
serde_json = { version = "1.0" } | ||
smpl_jwt = { version = "0.7" } | ||
thiserror = { version = "1.0" } | ||
time = { version = "0.3", features = [ "serde-well-known" ] } | ||
tracing = { version = "0.1" } | ||
|
||
[dev-dependencies] | ||
anyhow = { version = "1.0" } | ||
base64 = { version = "0.21" } | ||
goauth = { version = "0.13" } | ||
proc-macro2 = { version = "1.0" } | ||
quote = { version = "1.0" } | ||
reqwest = { version = "0.11" } | ||
serde = { version = "1.0" } | ||
serde_json = { version = "1.0" } | ||
smpl_jwt = { version = "0.7" } | ||
syn = { version = "2.0" } | ||
testcontainers = { version = "0.15" } | ||
testcontainers-modules = { version = "0.1", features = [ "google_cloud_sdk_emulators" ] } | ||
thiserror = { version = "1.0" } | ||
time = { version = "0.3" } | ||
tokio = { version = "1" } | ||
tracing = { version = "0.1" } | ||
tracing-subscriber = { version = "0.3" } | ||
tokio = { version = "1", features = [ "macros", "rt-multi-thread" ] } | ||
tracing-subscriber = { version = "0.3", features = [ "env-filter", "fmt", "json" ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
pre-release-commit-message = "release: released {{crate_name}} v{{version}}" | ||
post-release-commit-message = "release: bumping {{crate_name}} to v{{next_version}}" | ||
dev-version = true | ||
pre-release-commit-message = "release: v{{version}}" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use reqwest::Response; | ||
use serde_json::Value; | ||
use std::{convert::identity, error::Error as StdError}; | ||
use thiserror::Error; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum Error { | ||
#[error("initialization error: {reason}")] | ||
Initialization { | ||
reason: String, | ||
source: Box<dyn StdError + Send + Sync + 'static>, | ||
}, | ||
|
||
#[error("getting authentication token failed")] | ||
TokenFetch(#[from] Box<goauth::GoErr>), | ||
|
||
#[error("HTTP communication with Pub/Sub service failed")] | ||
HttpServiceCommunication(#[source] reqwest::Error), | ||
#[error("unexpected HTTP status code `{0}` from Pub/Sub service: {1}")] | ||
UnexpectedHttpStatusCode(reqwest::StatusCode, String), | ||
#[error("unexpected HTTP response from Pub/Sub service")] | ||
UnexpectedHttpResponse(#[source] reqwest::Error), | ||
|
||
#[error("decoding data of received message as Base64 failed")] | ||
DecodeBase64(#[source] base64::DecodeError), | ||
#[error("message contains no data")] | ||
NoData, | ||
#[error("deserializing data of received message failed")] | ||
Deserialize(#[source] serde_json::Error), | ||
#[error("serializing of message to be published failed")] | ||
Serialize(#[source] serde_json::Error), | ||
#[error("failed to transform JSON value")] | ||
Transform(#[source] Box<dyn StdError + Send + Sync + 'static>), | ||
} | ||
|
||
impl Error { | ||
pub async fn unexpected_http_status_code(response: Response) -> Error { | ||
Error::UnexpectedHttpStatusCode( | ||
response.status(), | ||
response | ||
.text() | ||
.await | ||
.map_err(|e| format!("failed to get response body as text: {e}")) | ||
.and_then(|text| { | ||
serde_json::from_str::<Value>(&text) | ||
.map_err(|e| format!("failed to parse error response: {e}")) | ||
.map(|v| v["error"]["message"].to_string()) | ||
}) | ||
.unwrap_or_else(identity), | ||
) | ||
} | ||
} |
Oops, something went wrong.