Skip to content

Commit

Permalink
refactor: move xlineapi export to types
Browse files Browse the repository at this point in the history
Signed-off-by: bsbds <[email protected]>
  • Loading branch information
bsbds committed Aug 3, 2023
1 parent 7179e5a commit a012230
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
4 changes: 0 additions & 4 deletions xline-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ pub mod error;
mod lease_gen;
/// Request type definitions.
pub mod types;
/// Xline proto types API
pub mod api_types {
pub use xlineapi::*;
}

/// Xline client
#[derive(Clone, Debug)]
Expand Down
10 changes: 9 additions & 1 deletion xline-client/src/types/auth.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
use xline::server::KeyRange;
use xlineapi::Type as PermissionType;

pub use xlineapi::{
AuthDisableResponse, AuthEnableResponse, AuthRoleAddResponse, AuthRoleDeleteResponse,
AuthRoleGetResponse, AuthRoleGrantPermissionResponse, AuthRoleListResponse,
AuthRoleRevokePermissionResponse, AuthStatusResponse, AuthUserAddResponse,
AuthUserChangePasswordResponse, AuthUserDeleteResponse, AuthUserGetResponse,
AuthUserGrantRoleResponse, AuthUserListResponse, AuthUserRevokeRoleResponse,
AuthenticateResponse, Type as PermissionType,
};

/// Request for `Authenticate`
#[derive(Debug)]
Expand Down
6 changes: 5 additions & 1 deletion xline-client/src/types/kv.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use xline::server::KeyRange;
use xlineapi::{CompareResult, CompareTarget, SortOrder, SortTarget, TargetUnion};

pub use xlineapi::{
CompareResult, CompareTarget, DeleteRangeResponse, PutResponse, RangeResponse, Response,
ResponseOp, SortOrder, SortTarget, TargetUnion, TxnResponse,
};

/// Request type for `Put`
#[derive(Debug, PartialEq)]
Expand Down
5 changes: 5 additions & 0 deletions xline-client/src/types/lease.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
use crate::error::{ClientError, Result};
use futures::channel::mpsc::Sender;

pub use xlineapi::{
LeaseGrantResponse, LeaseKeepAliveResponse, LeaseLeasesResponse, LeaseRevokeResponse,
LeaseStatus, LeaseTimeToLiveResponse,
};

/// The lease keep alive handle.
#[derive(Debug)]
pub struct LeaseKeeper {
Expand Down
2 changes: 2 additions & 0 deletions xline-client/src/types/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use xlineapi::{RequestUnion, WatchCancelRequest, WatchProgressRequest};

use crate::error::{ClientError, Result};

pub use xlineapi::{Event, EventType, KeyValue, WatchResponse};

/// The watching handle.
#[derive(Debug)]
pub struct Watcher {
Expand Down
13 changes: 6 additions & 7 deletions xline-client/tests/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use xline_client::{
AuthRoleAddRequest, AuthRoleDeleteRequest, AuthRoleGetRequest,
AuthRoleGrantPermissionRequest, AuthRoleRevokePermissionRequest, AuthUserAddRequest,
AuthUserChangePasswordRequest, AuthUserDeleteRequest, AuthUserGetRequest,
AuthUserGrantRoleRequest, AuthUserRevokeRoleRequest, Permission,
AuthUserGrantRoleRequest, AuthUserRevokeRoleRequest, Permission, PermissionType,
},
};
use xlineapi::Type;

mod common;

Expand Down Expand Up @@ -57,11 +56,11 @@ async fn permission_operations_should_success_in_normal_path() -> Result<()> {
let client = client.auth_client();

let role1 = "role1";
let perm1 = Permission::new(Type::Read, "123");
let perm2 = Permission::new(Type::Write, "abc").with_from_key();
let perm3 = Permission::new(Type::Readwrite, "hi").with_range_end("hjj");
let perm4 = Permission::new(Type::Write, "pp").with_prefix();
let perm5 = Permission::new(Type::Read, vec![0]).with_from_key();
let perm1 = Permission::new(PermissionType::Read, "123");
let perm2 = Permission::new(PermissionType::Write, "abc").with_from_key();
let perm3 = Permission::new(PermissionType::Readwrite, "hi").with_range_end("hjj");
let perm4 = Permission::new(PermissionType::Write, "pp").with_prefix();
let perm5 = Permission::new(PermissionType::Read, vec![0]).with_from_key();

client.role_add(AuthRoleAddRequest::new(role1)).await?;

Expand Down
4 changes: 2 additions & 2 deletions xline-client/tests/kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use test_macros::abort_on_panic;
use xline_client::{
error::Result,
types::kv::{
CompactionRequest, Compare, DeleteRangeRequest, PutRequest, RangeRequest, TxnOp, TxnRequest,
CompactionRequest, Compare, CompareResult, DeleteRangeRequest, PutRequest, RangeRequest,
TxnOp, TxnRequest,
},
};
use xlineapi::CompareResult;

mod common;

Expand Down
7 changes: 5 additions & 2 deletions xline-client/tests/watch.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! The following tests are originally from `etcd-client`
use crate::common::get_cluster_client;
use xline_client::{error::Result, types::kv::PutRequest, types::watch::WatchRequest};
use xlineapi::EventType;
use xline_client::{
error::Result,
types::kv::PutRequest,
types::watch::{EventType, WatchRequest},
};

mod common;

Expand Down

0 comments on commit a012230

Please sign in to comment.