Skip to content

Commit

Permalink
Optimize the codes
Browse files Browse the repository at this point in the history
  • Loading branch information
rmqtt committed Feb 24, 2024
1 parent c3418eb commit 3b8e3ff
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion rmqtt-plugins/rmqtt-retainer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ use config::PluginConfig;
use retainer::Retainer;
use rmqtt::broker::RetainStorage;
use rmqtt::grpc::MessageType;
use rmqtt::{async_trait::async_trait, log, serde_json, tokio::sync::RwLock, tokio_cron_scheduler::Job};
use rmqtt::{
async_trait::async_trait,
log,
serde_json::{self, json},
tokio::sync::RwLock,
tokio_cron_scheduler::Job,
};
use rmqtt::{
broker::hook::{Handler, HookResult, Parameter, Register, ReturnType, Type},
grpc::{Message, MessageReply},
Expand Down Expand Up @@ -105,6 +111,16 @@ impl Plugin for RetainerPlugin {
//self.register.stop().await;
Ok(false)
}

#[inline]
async fn attrs(&self) -> serde_json::Value {
let count = self.retainer.count();
let max = self.retainer.max();
json!({
"count": count,
"max": max,
})
}
}

struct RetainHandler {
Expand Down

0 comments on commit 3b8e3ff

Please sign in to comment.