Skip to content

Commit 214a09a

Browse files
authored
Added status 503 for connection issue
2 parents 7e2586e + ab284f0 commit 214a09a

10 files changed

Lines changed: 35 additions & 15 deletions

File tree

CONTRIBUTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# How to Contribute
2+
1. Create a release branch and a pull request to the `main` branch
3+
2. Push your changes, and ensure versions for the following packages are incremented appropriately:
4+
* `Cargo.toml`
5+
* `xyo-http/Cargo.toml`
6+
* `example/Cargo.toml`
7+
3. Monitor the pipeline to pass with a green light
8+
4. Merge to the `main` branch and delete the release branch
9+
5. Create a new tag according matching incremented version in `Cargo.toml` files
10+
* `git tag 1.x.x`
11+
* `git push origin 1.x.x`
12+
6. Push the new tag to the remote repository and monitor two pipelines
13+
* Pipeline will be triggered to first publish `xyo-http` package
14+
* On Failure or Success from previous pipeline, it will execute the publication for `xyo-sdk`
15+
7. All pipelines should pass with a green light indicating the successful publishing on Crates.io

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ workspace = { members = ["xyo-http"], exclude = ["example"] }
22
[package]
33
name = "xyo-sdk"
44
description = "XYO Financial Official SDK for Rust"
5-
version = "1.1.1"
5+
version = "1.1.2"
66
edition = "2021"
77
authors = [
88
"Hadi Tajallaei <hadi@syniol.com>"
@@ -26,4 +26,4 @@ exclude = [
2626
[dependencies]
2727
serde = { version = "1.0.219", features = ["derive"] }
2828
serde_json = "1.0.143"
29-
xyo-http = { version = "1.1.1", path = "xyo-http" }
29+
xyo-http = { version = "1.1.2", path = "xyo-http" }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use xyo_sdk::client::{new, ClientConfig};
2525

2626
fn main() {
2727
let client = new(ClientConfig {
28-
api_key: "YourAPIKeyFromXYO.FinancialDashboard"
28+
api_key: "your-api-key-from:xyo.Financial"
2929
});
3030
}
3131
```

example/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
xyo-sdk = { version = "1.1.1", path = ".." }
9+
xyo-sdk = { version = "1.1.2", path = ".." }

src/client.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ impl Enrichment for Client {
2626
serde_json::to_string(rq).unwrap().as_str(),
2727
);
2828
if resp.is_err() {
29+
let err = resp.err().unwrap();
2930
return Err(ClientError{
30-
code: 0,
31-
message: resp.err().unwrap().message,
31+
code: err.code,
32+
message: err.message,
3233
})
3334
}
3435

@@ -57,9 +58,10 @@ impl Enrichment for Client {
5758
serde_json::to_string(&rq).unwrap().as_str(),
5859
);
5960
if resp.is_err() {
61+
let err = resp.err().unwrap();
6062
return Err(ClientError{
61-
code: 0,
62-
message: resp.err().unwrap().message,
63+
code: err.code,
64+
message: err.message,
6365
})
6466
}
6567

@@ -89,9 +91,10 @@ impl Enrichment for Client {
8991
"",
9092
);
9193
if resp.is_err() {
94+
let err = resp.err().unwrap();
9295
return Err(ClientError{
93-
code: 0,
94-
message: resp.err().unwrap().message,
96+
code: err.code,
97+
message: err.message,
9598
})
9699
}
97100

xyo-http/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "xyo-http"
33
description = "http client used for XYO Financial SDK"
4-
version = "1.1.1"
4+
version = "1.1.2"
55
edition = "2021"
66
authors = [
77
"Hadi Tajallaei <hadi@syniol.com>"

xyo-http/src/err.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#[derive(Debug)]
22
pub struct HttpClientError {
3+
pub code: i16,
34
pub message: String,
45
}

xyo-http/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ mod http_message {
4646
pub fn request(method: HttpMethod, path: &str, data: &str) -> Result<String, HttpClientError> {
4747
let Ok(mut tcp_stream_socket) = TcpStream::connect(format!("{}:{}", HOST, PORT)) else {
4848
return Err(HttpClientError{
49+
code: 503,
4950
message: format!("could not connect to host: {} and port number {}", HOST, PORT),
5051
})
5152
};

0 commit comments

Comments
 (0)