Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
hunjixin committed Aug 9, 2024
1 parent 7fb4352 commit 590a471
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy rustfmt

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Run Clippy
run: cargo +nightly clippy --fix --workspace --exclude jiaozifs_client_rs --allow-dirty

Expand Down
10 changes: 1 addition & 9 deletions src/bin/jz-flow/job.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
use std::{
io::{
self,
stdout,
},
iter,
os::linux::raw::stat,
str::FromStr,
};
use std::str::FromStr;

use crate::global::GlobalOptions;
use anyhow::Result;
Expand Down
3 changes: 1 addition & 2 deletions src/dbrepo/job_db_mongo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::os::linux::raw::stat;

use crate::{
core::db::{
Expand Down Expand Up @@ -259,7 +258,7 @@ impl DataRepo for MongoRunDbRepo {
direction: Option<&Direction>,
) -> Result<usize> {
let mut query = doc! {"node_name":node_name};
if states.len() > 0 {
if !states.is_empty() {
let states: Vec<&str> = states.iter().map(to_variant_name).try_collect()?;
query.insert("state", doc! {"$in": states});
}
Expand Down
18 changes: 6 additions & 12 deletions src/driver/kube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,16 @@ use handlebars::{
RenderContext,
RenderError,
};
use k8s_metrics::{
v1beta1 as metricsv1,
QuantityExt,
};
use k8s_openapi::{
api::{
use k8s_metrics::v1beta1 as metricsv1;
use k8s_openapi::api::{
apps::v1::StatefulSet,
core::v1::{
Namespace,
PersistentVolumeClaim,
Pod,
Service,
},
},
apimachinery::pkg::api::resource::Quantity,
};
};
use kube::{
api::{
DeleteParams,
Expand Down Expand Up @@ -145,7 +139,7 @@ where
let mut node_status = NodeStatus {
name: self.node_name.clone(),
state: db_node.state,
data_count: data_count,
data_count,
replicas: statefulset
.spec
.as_ref()
Expand Down Expand Up @@ -280,7 +274,7 @@ where
let mut node_status = NodeStatus {
name: self.node_name.clone(),
state: db_node.state,
data_count: data_count,
data_count,
replicas: statefulset
.spec
.as_ref()
Expand Down Expand Up @@ -373,7 +367,7 @@ where
fn new(repo: R, client: Client,topo_sort_nodes: Vec<String>) -> Self {
Self {
_db_repo: repo,
topo_sort_nodes:topo_sort_nodes,
topo_sort_nodes,
_client: client,
handlers: Default::default(),
}
Expand Down
10 changes: 3 additions & 7 deletions src/job/job_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@ use crate::{
};
use anyhow::Result;
use futures::future::try_join_all;
use k8s_openapi::api::node;
use kube::Client;
use mongodb::bson::oid::ObjectId;
use serde::{
Deserialize,
Serialize,
};
use std::{
collections::HashMap,
marker::PhantomData,
};
use std::marker::PhantomData;
use tokio::task::JoinSet;
use tokio_util::sync::CancellationToken;
use tracing::{
Expand Down Expand Up @@ -177,7 +173,7 @@ where
let namespace = format!("{}-{}", job.name, job.retry_number - 1);
self.db
.update(
&id,
id,
&JobUpdateInfo {
state: Some(JobState::Finish),
},
Expand All @@ -186,7 +182,7 @@ where
self.driver.clean(&namespace).await?;
self.db
.update(
&id,
id,
&JobUpdateInfo {
state: Some(JobState::Clean),
},
Expand Down

0 comments on commit 590a471

Please sign in to comment.