Skip to content
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
8 changes: 3 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@ on:
push:
branches:
- main
- staging
- trying
- "renovate/**"
tags:
- "*"
pull_request:
merge_group:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, beta, nightly]
zookeeper: [3.8.1, 3.7.1, 3.6.4, 3.5.10]
zookeeper: [3.9.2, 3.8.4, 3.7.2, 3.6.4, 3.5.10]
steps:
- name: Check out repository code
uses: actions/checkout@v3
- run: rustup default ${{ matrix.rust }}
- run: wget -O zookeeper.tar.gz https://dlcdn.apache.org/zookeeper/zookeeper-${{ matrix.zookeeper }}/apache-zookeeper-${{ matrix.zookeeper }}-bin.tar.gz
- run: wget -O zookeeper.tar.gz https://archive.apache.org/dist/zookeeper/zookeeper-${{ matrix.zookeeper }}/apache-zookeeper-${{ matrix.zookeeper }}-bin.tar.gz
- run: mkdir zookeeper
- run: tar -zxvf zookeeper.tar.gz -C zookeeper --strip-components 1
- run: ./scripts/ci-start-zookeeper
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Changed

- [BREAKING] Migrated errors from Failure to SNAFU ([#39]).
- Updated ZooKeeper versions we test against (now 3.9.2, 3.8.4, 3.7.2, 3.6.4, 3.5.10) ([#39]).

[#39]: https://github.com/stackabletech/tokio-zookeeper/pull/39

## [0.2.1] - 2023-02-13

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ maintenance = { status = "experimental" }
[dependencies]
futures = "0.3"
tokio = { version = "1.22", features = ["net", "rt", "time"] }
failure = "0.1"
byteorder = "1.2"
slog = "2.3.2"
async-trait = "0.1.58"
pin-project = "1.0.12"
once_cell = "1.17.0"
snafu = "0.8.2"
#slog = { version = "2.3.2", features = ['max_level_trace'] }

[dev-dependencies]
Expand Down
124 changes: 53 additions & 71 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,173 +1,155 @@
use failure::Fail;
use snafu::Snafu;

/// Errors that may cause a delete request to fail.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Fail)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Snafu)]
#[snafu(module)]
pub enum Delete {
/// No node exists with the given `path`.
#[fail(display = "target node does not exist")]
#[snafu(display("target node does not exist"))]
NoNode,

/// The target node has a different version than was specified by the call to delete.
#[fail(
display = "target node has different version than expected ({})",
expected
)]
#[snafu(display("target node has different version than expected ({expected})"))]
BadVersion {
/// The expected node version.
expected: i32,
},

/// The target node has child nodes, and therefore cannot be deleted.
#[fail(display = "target node has children, and cannot be deleted")]
#[snafu(display("target node has children, and cannot be deleted"))]
NotEmpty,
}

/// Errors that may cause a `set_data` request to fail.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Fail)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Snafu)]
#[snafu(module)]
pub enum SetData {
/// No node exists with the given `path`.
#[fail(display = "target node does not exist")]
#[snafu(display("target node does not exist"))]
NoNode,

/// The target node has a different version than was specified by the call to `set_data`.
#[fail(
display = "target node has different version than expected ({})",
expected
)]
#[snafu(display("target node has different version than expected ({expected})"))]
BadVersion {
/// The expected node version.
expected: i32,
},

/// The target node's permission does not accept data modification or requires different
/// authentication to be altered.
#[fail(display = "insuficient authentication")]
#[snafu(display("insuficient authentication"))]
NoAuth,
}

/// Errors that may cause a create request to fail.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Fail)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Snafu)]
#[snafu(module)]
pub enum Create {
/// A node with the given `path` already exists.
#[fail(display = "target node already exists")]
#[snafu(display("target node already exists"))]
NodeExists,

/// The parent node of the given `path` does not exist.
#[fail(display = "parent node of target does not exist")]
#[snafu(display("parent node of target does not exist"))]
NoNode,

/// The parent node of the given `path` is ephemeral, and cannot have children.
#[fail(display = "parent node is ephemeral, and cannot have children")]
#[snafu(display("parent node is ephemeral, and cannot have children"))]
NoChildrenForEphemerals,

/// The given ACL is invalid.
#[fail(display = "the given ACL is invalid")]
#[snafu(display("the given ACL is invalid"))]
InvalidAcl,
}

/// Errors that may cause a `get_acl` request to fail.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Fail)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Snafu)]
#[snafu(module)]
pub enum GetAcl {
/// No node exists with the given `path`.
#[fail(display = "target node does not exist")]
#[snafu(display("target node does not exist"))]
NoNode,
}

/// Errors that may cause a `set_acl` request to fail.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Fail)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Snafu)]
#[snafu(module)]
pub enum SetAcl {
/// No node exists with the given `path`.
#[fail(display = "target node does not exist")]
#[snafu(display("target node does not exist"))]
NoNode,

/// The target node has a different version than was specified by the call to `set_acl`.
#[fail(
display = "target node has different version than expected ({})",
expected
)]
#[snafu(display("target node has different version than expected ({expected})"))]
BadVersion {
/// The expected node version.
expected: i32,
},

/// The given ACL is invalid.
#[fail(display = "the given ACL is invalid")]
#[snafu(display("the given ACL is invalid"))]
InvalidAcl,

/// The target node's permission does not accept acl modification or requires different
/// authentication to be altered.
#[fail(display = "insufficient authentication")]
#[snafu(display("insufficient authentication"))]
NoAuth,
}

/// Errors that may cause a `check` request to fail.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Fail)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Snafu)]
#[snafu(module)]
pub enum Check {
/// No node exists with the given `path`.
#[fail(display = "target node does not exist")]
#[snafu(display("target node does not exist"))]
NoNode,

/// The target node has a different version than was specified by the call to `check`.
#[fail(
display = "target node has different version than expected ({})",
expected
)]
#[snafu(display("target node has different version than expected ({expected})"))]
BadVersion {
/// The expected node version.
expected: i32,
},
}

/// The result of a failed `multi` request.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Fail)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Snafu)]
pub enum Multi {
/// A failed `delete` request.
#[fail(display = "delete failed: {}", 0)]
Delete(Delete),
#[snafu(display("delete failed"), context(false))]
Delete {
/// The source error.
source: Delete,
},

/// A failed `set_data` request.
#[fail(display = "set_data failed: {}", 0)]
SetData(SetData),
#[snafu(display("set_data failed"), context(false))]
SetData {
/// The source error.
source: SetData,
},

/// A failed `create` request.
#[fail(display = "create failed: {}", 0)]
Create(Create),
#[snafu(display("create failed"), context(false))]
Create {
/// The source error.
source: Create,
},

/// A failed `check` request.
#[fail(display = "check failed")]
Check(Check),
#[snafu(display("check failed"), context(false))]
Check {
/// The source error.
source: Check,
},

/// The request would have succeeded, but a later request in the `multi`
/// batch failed and caused this request to get rolled back.
#[fail(display = "request rolled back due to later failed request")]
#[snafu(display("request rolled back due to later failed request"))]
RolledBack,

/// The request was skipped because an earlier request in the `multi` batch
/// failed. It is unknown whether this request would have succeeded.
#[fail(display = "request failed due to earlier failed request")]
#[snafu(display("request failed due to earlier failed request"))]
Skipped,
}

impl From<Delete> for Multi {
fn from(err: Delete) -> Self {
Multi::Delete(err)
}
}

impl From<SetData> for Multi {
fn from(err: SetData) -> Self {
Multi::SetData(err)
}
}

impl From<Create> for Multi {
fn from(err: Create) -> Self {
Multi::Create(err)
}
}

impl From<Check> for Multi {
fn from(err: Check) -> Self {
Multi::Check(err)
}
}
Loading