Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: reordered error behavior variants to make ignore default #325

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/components/wick-azure-sql/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,11 @@ async fn handle_call(
if let Err(e) = handle_stream(&mut client, opdef, input_streams, tx, stmt.clone(), span).await {
match error_behavior {
wick_config::config::ErrorBehavior::Commit => {
error!(error=%e, on_error=?error_behavior, "error in sql operation, committing transaction");
client.simple_query("COMMIT").await.map_err(|_| Error::TxCommit)?;
}
wick_config::config::ErrorBehavior::Rollback => {
error!(error=%e, on_error=?error_behavior, "error in sql operation, rolling back transaction");
client.simple_query("ROLLBACK").await.map_err(|_| Error::TxRollback)?;
}
_ => {}
Expand Down
9 changes: 4 additions & 5 deletions crates/wick/wick-config/definitions/v1/manifest.apex
Original file line number Diff line number Diff line change
Expand Up @@ -786,15 +786,14 @@ type SqlOperationDefinition {

"What to do when an error occurs."
enum ErrorBehavior {
"Errors will be ignored."
Ignore = 0 as "ignore",
"The operation will commit what has succeeded."
Commit = 0 as "commit",
Commit = 1 as "commit",
"The operation will rollback changes."
Rollback = 1 as "rollback",
"Errors will be ignored."
Ignore = 2 as "ignore",
Rollback = 2 as "rollback",
}


"A component whose operations are HTTP requests."
type HttpClientComponent @tagged("wick/component/http@v1") {
"The URL base to use."
Expand Down
2 changes: 1 addition & 1 deletion crates/wick/wick-config/docs/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -1525,9 +1525,9 @@ Any one of the following types:

| Field name | Type | Description |
|------------|------|-------------|
| Ignore | unknown type | Errors will be ignored. |
| Commit | unknown type | The operation will commit what has succeeded. |
| Rollback | unknown type | The operation will rollback changes. |
| Ignore | unknown type | Errors will be ignored. |


--------
Expand Down
4 changes: 2 additions & 2 deletions crates/wick/wick-config/json-schema/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2510,9 +2510,9 @@
"ErrorBehavior": {
"$anchor": "#v1/ErrorBehavior",
"enum": [
"Ignore",
"Commit",
"Rollback",
"Ignore"
"Rollback"
]
},
"HttpClientComponent": {
Expand Down
2 changes: 1 addition & 1 deletion crates/wick/wick-config/json-schema/v1/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,7 @@

"ErrorBehavior": {
"$anchor": "#v1/ErrorBehavior",
"enum": ["Commit", "Rollback", "Ignore"]
"enum": ["Ignore", "Commit", "Rollback"]
},

"HttpClientComponent": {
Expand Down
20 changes: 10 additions & 10 deletions crates/wick/wick-config/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1499,12 +1499,12 @@ pub(crate) struct SqlOperationDefinition {
#[serde(deny_unknown_fields)]
/// What to do when an error occurs.
pub(crate) enum ErrorBehavior {
/// Errors will be ignored.
Ignore = 0,
/// The operation will commit what has succeeded.
Commit = 0,
Commit = 1,
/// The operation will rollback changes.
Rollback = 1,
/// Errors will be ignored.
Ignore = 2,
Rollback = 2,
}

impl Default for ErrorBehavior {
Expand All @@ -1516,9 +1516,9 @@ impl Default for ErrorBehavior {
impl FromPrimitive for ErrorBehavior {
fn from_i64(n: i64) -> Option<Self> {
Some(match n {
0 => Self::Commit,
1 => Self::Rollback,
2 => Self::Ignore,
0 => Self::Ignore,
1 => Self::Commit,
2 => Self::Rollback,
_ => {
return None;
}
Expand All @@ -1527,9 +1527,9 @@ impl FromPrimitive for ErrorBehavior {

fn from_u64(n: u64) -> Option<Self> {
Some(match n {
0 => Self::Commit,
1 => Self::Rollback,
2 => Self::Ignore,
0 => Self::Ignore,
1 => Self::Commit,
2 => Self::Rollback,
_ => {
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/configuration/reference/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -1525,9 +1525,9 @@ Any one of the following types:

| Field name | Type | Description |
|------------|------|-------------|
| Ignore | unknown type | Errors will be ignored. |
| Commit | unknown type | The operation will commit what has succeeded. |
| Rollback | unknown type | The operation will rollback changes. |
| Ignore | unknown type | Errors will be ignored. |


--------
Expand Down